tests: sprintf: Avoid buffer overrun
fwrite parameters are "size_t size" and "size_t nmemb", when writing a string we should set sizeof(char) and len(string). The test is doing it wrongly and making the function read more memory than it should. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
4163ea0207
commit
417747886c
|
@ -909,10 +909,10 @@ ZTEST(sprintf, test_fwrite)
|
|||
ret = fwrite("This 3", 0, 4, stdout);
|
||||
zassert_equal(ret, 0, "fwrite failed!");
|
||||
|
||||
ret = fwrite("This 3", 4, 4, stdout);
|
||||
ret = fwrite("This 3", 1, 4, stdout);
|
||||
zassert_equal(ret, 4, "fwrite failed!");
|
||||
|
||||
ret = fwrite("This 3", 4, 4, stdin);
|
||||
ret = fwrite("This 3", 1, 4, stdin);
|
||||
zassert_equal(ret, 0, "fwrite failed!");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue