[Bug 202240] fwscanf return EOF instead of ZERO in the event of matching failure

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Tue Aug 11 07:11:25 UTC 2015


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=202240

            Bug ID: 202240
           Summary: fwscanf return EOF instead of ZERO in the event of
                    matching failure
           Product: Base System
           Version: 11.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: kern
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: rajendra.sy at gmail.com

Created attachment 159753
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=159753&action=edit
Source file compares fwscanf & fscanf return values

The function fwscanf() return value is wrong incase of invalid input character.

For example:
     int ret = fwscanf(fptr, L"j%s", buf);

The above call should return ZERO for matching failure.

Possible fix:
--- a/lib/libc/stdio/vfwscanf.c
+++ b/lib/libc/stdio/vfwscanf.c
@@ -492,7 +492,7 @@ literal:
                                goto input_failure;
                        if (wi != c) {
                                __ungetwc(wi, fp, locale);
-                               goto input_failure;
+                               goto match_failure;
                        }
                        nread++;
                        continue;

The fscanf() function behaves correctly. Compared the source of both functions
confirms the return is value is wrong.

Attached a source file to reproduce the problem.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list