Fix a case of undefined behavior due to overlapping buf objects in
snprintf (buf, size, fmt, buf, etc). This only works by chance with our libc, but fails (with a truncated string) on e.g. glibc. Okayed by: sobomax MFC after: 1 week
This commit is contained in:
parent
79e51fd0d7
commit
0e961ee647
@ -236,13 +236,14 @@ int
|
||||
isinstalledpkg(const char *name)
|
||||
{
|
||||
char buf[FILENAME_MAX];
|
||||
char buf2[FILENAME_MAX];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/%s", LOG_DIR, name);
|
||||
if (!isdir(buf) || access(buf, R_OK) == FAIL)
|
||||
return FALSE;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/%s", buf, CONTENTS_FNAME);
|
||||
if (!isfile(buf) || access(buf, R_OK) == FAIL)
|
||||
snprintf(buf2, sizeof(buf2), "%s/%s", buf, CONTENTS_FNAME);
|
||||
if (!isfile(buf2) || access(buf2, R_OK) == FAIL)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user