Oops, fixup remnants of old realpath() semantics in fingerprinting

The subsequent code relied on buffer lenght being explicit PATH_MAX
which certainly was no longer the case. Clearly, our test-suite does
not excercise this code...

Should've been in commit b1bc46e56a
This commit is contained in:
Panu Matilainen 2022-05-06 11:27:10 +03:00
parent 09ad6fa904
commit 328ff700a3
1 changed files with 3 additions and 7 deletions

View File

@ -148,15 +148,11 @@ static char * canonDir(rpmstrPool pool, rpmsid dirNameId)
* the result.
*/
/* if the current directory doesn't exist, we might fail.
oh well. likewise if it's too long. */
/* if the current directory doesn't exist, we might fail. oh well. */
if ((cdnbuf = realpath(".", NULL)) != NULL) {
char *end = cdnbuf + strlen(cdnbuf);
if (end[-1] != '/') *end++ = '/';
end = stpncpy(end, dirName, PATH_MAX - (end - cdnbuf));
*end = '\0';
cdnbuf = rstrscat(&cdnbuf, "/", dirName, NULL);
(void)rpmCleanPath(cdnbuf); /* XXX possible /../ from concatenation */
end = cdnbuf + strlen(cdnbuf);
char *end = cdnbuf + strlen(cdnbuf);
if (end[-1] != '/') *end++ = '/';
*end = '\0';
}