mirror of
https://github.com/gluster/glusterfs.git
synced 2026-02-05 15:48:40 +01:00
glfs-fops.c: fix the bad string length for snprintf
Snprintf reserves one byte for the ending '\0'. A NAME_MAX bytes d_name is truncated to NAME_MAX - 1 bytes. Change-Id: Ic884d18cee24360e55ddb896dc587b0b74ef97fe updates: bz#1193929 Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
This commit is contained in:
committed by
Niels de Vos
parent
a9b0003c71
commit
f99f51ca87
@@ -3413,7 +3413,7 @@ gf_dirent_to_dirent(gf_dirent_t *gf_dirent, struct dirent *dirent)
|
||||
dirent->d_namlen = strlen(gf_dirent->d_name);
|
||||
#endif
|
||||
|
||||
snprintf(dirent->d_name, NAME_MAX, "%s", gf_dirent->d_name);
|
||||
snprintf(dirent->d_name, NAME_MAX + 1, "%s", gf_dirent->d_name);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -4904,7 +4904,7 @@ retry:
|
||||
goto out;
|
||||
|
||||
if (loc.path) {
|
||||
snprintf(retpath, PATH_MAX, "%s", loc.path);
|
||||
snprintf(retpath, PATH_MAX + 1, "%s", loc.path);
|
||||
}
|
||||
|
||||
out:
|
||||
|
||||
Reference in New Issue
Block a user