projects
/
fw
/
pdclib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Proper handling of end-of-string.
[fw/pdclib]
/
functions
/
stdio
/
vsscanf.c
diff --git
a/functions/stdio/vsscanf.c
b/functions/stdio/vsscanf.c
index 8a2379026af56d13040fff21589cc8247bc365ff..be9bf61ae16ba5c699e718fc2d5285fa708c17b8 100644
(file)
--- a/
functions/stdio/vsscanf.c
+++ b/
functions/stdio/vsscanf.c
@@
-48,6
+48,11
@@
int vsscanf( const char * _PDCLIB_restrict s, const char * _PDCLIB_restrict form
/* Non-whitespace char in format string: Match verbatim */
if ( *status.s != *format )
{
/* Non-whitespace char in format string: Match verbatim */
if ( *status.s != *format )
{
+ if ( *status.s == '\0' && status.n == 0 )
+ {
+ /* Early input error */
+ return EOF;
+ }
/* Matching error */
return status.n;
}
/* Matching error */
return status.n;
}
@@
-61,9
+66,13
@@
int vsscanf( const char * _PDCLIB_restrict s, const char * _PDCLIB_restrict form
}
else
{
}
else
{
- /* NULL return code indicates
input
error */
+ /* NULL return code indicates error */
if ( rc == NULL )
{
if ( rc == NULL )
{
+ if ( ( *status.s == '\n' ) && ( status.n == 0 ) )
+ {
+ status.n = EOF;
+ }
break;
}
/* Continue parsing after conversion specifier */
break;
}
/* Continue parsing after conversion specifier */