]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commit
fstests: t_getcwd.c, fix a warning related to buffer overflow
authorAnand Jain <anand.jain@oracle.com>
Sun, 29 Jan 2023 02:42:32 +0000 (10:42 +0800)
committerZorro Lang <zlang@kernel.org>
Fri, 3 Feb 2023 18:06:30 +0000 (02:06 +0800)
commitc569ebf561802dd43492ccb47df90528645dc7c6
treeedf16387e0171ed25597ed4adb31647a3681ed1c
parent8d8d05a8e222658931310f55dfbe65edd8e80932
fstests: t_getcwd.c, fix a warning related to buffer overflow

GCC reports warning related to 'strncpy' and its specified bound being
equal to the destination buffer size.

t_getcwd.c: In function 'do_rename':
t_getcwd.c:40:2: warning: 'strncpy' specified bound 256 equals destination size [-Wstringop-truncation]
  strncpy(c_name, prefix, BUF_SIZE);

A buffer overflow is unlikely here because the only caller for
do_rename() sends a 16 char long %prefix and BUF_SIZE is defined as 256.

The change is made to reduce the buffer length in order to silence
compilation warning.

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>
src/t_getcwd.c