FindModuleInSubdir: Stop allocating one more byte than needed

15ac25627e removed the "/" from the sprintf strings,
but failed to remove the extra byte allocated for the '/'.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
This commit is contained in:
Alan Coopersmith 2010-11-27 20:43:28 -08:00
parent 40d5a01935
commit 685286b17d

View File

@ -406,21 +406,21 @@ FindModuleInSubdir(const char *dirpath, const char *module)
snprintf(tmpBuf, PATH_MAX, "lib%s.so", module);
if (strcmp(direntry->d_name, tmpBuf) == 0) {
ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 2);
ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 1);
sprintf(ret, "%s%s", dirpath, tmpBuf);
break;
}
snprintf(tmpBuf, PATH_MAX, "%s_drv.so", module);
if (strcmp(direntry->d_name, tmpBuf) == 0) {
ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 2);
ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 1);
sprintf(ret, "%s%s", dirpath, tmpBuf);
break;
}
snprintf(tmpBuf, PATH_MAX, "%s.so", module);
if (strcmp(direntry->d_name, tmpBuf) == 0) {
ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 2);
ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 1);
sprintf(ret, "%s%s", dirpath, tmpBuf);
break;
}