mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 13:38:01 +00:00
vol: Use asprintf in _namei_examine_special
GCC-12 is flagging an snprintf statement with a format truncation warning: namei_ops.c: In function ‘namei_ListAFSSubDirs’: namei_ops.c:2029:22: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 0 and 511 [-Werror=format-truncation=] Change code to use asprintf instead of snprintf. Return an error if a memory allocation fails. Change-Id: I1f617ab22dbec4c2497ec482115cd20c9af0ecfa Reviewed-on: https://gerrit.openafs.org/14955 Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
parent
07076d63ed
commit
ae70db6cde
@ -2023,13 +2023,17 @@ _namei_examine_special(char * path1,
|
||||
* this like a normal file, we won't try to INC or DEC it. */
|
||||
info.linkCount = 0;
|
||||
} else {
|
||||
char path2[512];
|
||||
char *path2;
|
||||
/* Open this handle */
|
||||
snprintf(path2, sizeof(path2),
|
||||
"%s" OS_DIRSEP "%s", path1, dname);
|
||||
if (asprintf(&path2, "%s" OS_DIRSEP "%s", path1, dname) < 0) {
|
||||
Log("_namei_examine_special: memory allocation failure\n");
|
||||
ret = -1;
|
||||
goto error;
|
||||
}
|
||||
linkHandle->fd_fd = OS_OPEN(path2, Testing ? O_RDONLY : O_RDWR, 0666);
|
||||
info.linkCount =
|
||||
namei_GetLinkCount(linkHandle, (Inode) 0, 1, 1, Testing);
|
||||
free(path2);
|
||||
}
|
||||
|
||||
if (!judgeFun ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user