Commit 08d98f0f authored by Michał Janiszewski's avatar Michał Janiszewski Committed by Alexandre Julliard

msvcrt: Update size checks for secure scanf versions.

parent bab5a703
......@@ -548,13 +548,13 @@ _FUNCTION_ {
while (width && (nch != _EOF_))
{
if (!suppress) {
*str++ = _CHAR2SUPPORTED_(nch);
if(size) size--;
else {
_UNLOCK_FILE_(file);
*pstr = 0;
return rd;
}
*str++ = _CHAR2SUPPORTED_(nch);
}
st++;
width--;
......@@ -574,13 +574,13 @@ _FUNCTION_ {
while (width && (nch != _EOF_))
{
if (!suppress) {
*str++ = _WIDE2SUPPORTED_(nch);
if(size) size--;
else {
_UNLOCK_FILE_(file);
*pstr = 0;
return rd;
}
*str++ = _WIDE2SUPPORTED_(nch);
}
st++;
width--;
......
......@@ -282,10 +282,17 @@ static void test_sscanf_s(void)
ok(ret == 0, "Wrong number of arguments read: %d\n", ret);
ok(buf[0]=='\0', "buf = %s\n", buf);
buf[0] = 'a';
memset(buf, 'a', sizeof(buf));
ret = psscanf_s("123", "%3c", buf, 2);
ok(ret == 0, "Wrong number of arguments read: %d\n", ret);
ok(buf[0]=='\0', "buf = %s\n", buf);
ok(buf[1]=='2', "buf[1] = %d\n", buf[1]);
ok(buf[2]=='a', "buf[2] = %d\n", buf[2]);
buf[3] = 'a';
buf[4] = 0;
ret = psscanf_s("123", "%3c", buf, 3);
ok(!strcmp("123a", buf), "buf = %s\n", buf);
i = 1;
ret = psscanf_s("123 123", "%s %d", buf, 2, &i);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment