diff options
author | Anand Jain <anand.jain@oracle.com> | 2023-01-29 10:42:33 +0800 |
---|---|---|
committer | Zorro Lang <zlang@kernel.org> | 2023-02-04 02:06:30 +0800 |
commit | 1f12612b7c294af83b201f9c9056f8d4de0acb30 (patch) | |
tree | 5e46fba61b84f580812aab338f1a66f4599e771a /src | |
parent | c569ebf561802dd43492ccb47df90528645dc7c6 (diff) |
fstests: aiodio_sparse2.c, fix compiler warning buffer overflow
The warning is due to 'strncpy' with a maximum number of characters
equal to the destination buffer size, without space for null termination.
aiodio_sparse2.c: In function 'main':
aiodio_sparse2.c:404:9: warning: 'strncpy' specified bound 4096 equals destination size [-Wstringop-truncation]
404 | strncpy(filename, argv[argc-1], PATH_MAX);
However, PATH_MAX is including null termination at the end. Anyways, fix
warning by setting NULL.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/aio-dio-regress/aiodio_sparse2.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/aio-dio-regress/aiodio_sparse2.c b/src/aio-dio-regress/aiodio_sparse2.c index 51ede5bb..685e3b9d 100644 --- a/src/aio-dio-regress/aiodio_sparse2.c +++ b/src/aio-dio-regress/aiodio_sparse2.c @@ -402,6 +402,7 @@ int main(int argc, char **argv) } strncpy(filename, argv[argc-1], PATH_MAX); + filename[PATH_MAX - 1] = '\0'; if (alignment == 0) alignment = get_logical_block_size(filename); |