diff options
author | Tomohiro Kusumi <kusumi.tomohiro@gmail.com> | 2018-10-26 09:35:46 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-10-26 10:24:28 -0600 |
commit | 199710f5822cf22bf76107f26993a9468f93a422 (patch) | |
tree | a2e52f94574359a37e490bfa9f32cce306e4e82a /os | |
parent | a9d95828998ba65eff5a60df217d8d6ede6175bc (diff) | |
download | fio-199710f5822cf22bf76107f26993a9468f93a422.tar.gz fio-199710f5822cf22bf76107f26993a9468f93a422.tar.bz2 |
oslib: fix strlcat's incorrect copying
Fix unittests/oslib/strlcat.c test case failure.
oslib/strlcat.c implementation is incorrect for edge case inputs,
when (dsize-strlen(dst)-1 <= 0). The example below isn't supposed
to be copying anything, but the result is it does copy and
overruns the stack.
This commit replalces oslib/strlcat.c with the original implementation
under BSDL.
--
# uname
Linux
# cat ./test0.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "./oslib/strlcat.h"
int main(void) {
char *p, s[10] = "test";
int size = 200;
p = calloc(1, size);
memset(p, 65, size - 1);
printf("%lu %lu %s\n", sizeof(s), strlen(s), s);
strlcat(s, p, strlen(s));
printf("%lu %lu %s\n", sizeof(s), strlen(s), s);
return 0;
}
# gcc -Wall -g ./test0.c ./oslib/strlcat.c
# ./a.out
10 4 test
10 203 testAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Segmentation fault (core dumped)
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'os')
0 files changed, 0 insertions, 0 deletions