mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
aklog: Fix improper use of readlink
readlink doesn't NUL terminate its return string, so it is up to
us to do so.
Caught by coverity (#985739)
Reviewed-on: http://gerrit.openafs.org/9347
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
(cherry picked from commit 2fac53522e
)
Change-Id: I9d47a6a7cbc86fba3f68f7e47c5d7a0fb924781f
Reviewed-on: http://gerrit.openafs.org/11035
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
This commit is contained in:
parent
82f66b96fa
commit
e56dfc5c2c
@ -1211,12 +1211,16 @@ next_path(char *origpath)
|
||||
? elast_comp - last_comp : strlen(last_comp);
|
||||
strncat(pathtocheck, last_comp, len);
|
||||
memset(linkbuf, 0, sizeof(linkbuf));
|
||||
if ((link = (readlink(pathtocheck, linkbuf,
|
||||
sizeof(linkbuf)) > 0))) {
|
||||
link = readlink(pathtocheck, linkbuf, sizeof(linkbuf)-1);
|
||||
|
||||
if (link > 0) {
|
||||
linkbuf[link] = '\0'; /* NUL terminate string */
|
||||
|
||||
if (++symlinkcount > MAXSYMLINKS) {
|
||||
fprintf(stderr, "%s: %s\n", progname, strerror(ELOOP));
|
||||
exit(AKLOG_BADPATH);
|
||||
}
|
||||
|
||||
memset(tmpbuf, 0, sizeof(tmpbuf));
|
||||
if (elast_comp)
|
||||
strcpy(tmpbuf, elast_comp);
|
||||
|
Loading…
Reference in New Issue
Block a user