Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Aug 2015 07:11:24 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 202240] fwscanf return EOF instead of ZERO in the event of matching failure
Message-ID:  <bug-202240-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
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@FreeBSD.org
          Reporter: rajendra.sy@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-202240-8>