loader: Learn about the joy of snprintf
Reviewed-by: Julien Cristau <jcristau@debian.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
8e83eacb9e
commit
cc0f173ea2
|
@ -335,10 +335,7 @@ FindModule(const char *module, const char *dirname, PatternPtr patterns)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (s = stdSubdirs; *s; s++) {
|
for (s = stdSubdirs; *s; s++) {
|
||||||
if ((strlen(dirname) + strlen(*s)) > PATH_MAX)
|
snprintf(buf, PATH_MAX, "%s%s", dirname, *s);
|
||||||
continue;
|
|
||||||
strcpy(buf, dirname);
|
|
||||||
strcat(buf, *s);
|
|
||||||
if ((name = FindModuleInSubdir(buf, module)))
|
if ((name = FindModuleInSubdir(buf, module)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -371,11 +368,7 @@ LoaderListDir(const char *subdir, const char **patternlist)
|
||||||
goto bail;
|
goto bail;
|
||||||
|
|
||||||
for (elem = pathlist; *elem; elem++) {
|
for (elem = pathlist; *elem; elem++) {
|
||||||
if ((dirlen = strlen(*elem) + strlen(subdir) + 1) > PATH_MAX)
|
dirlen = snprintf(buf, PATH_MAX, "%s/%s", *elem, subdir);
|
||||||
continue;
|
|
||||||
strcpy(buf, *elem);
|
|
||||||
strcat(buf, "/");
|
|
||||||
strcat(buf, subdir);
|
|
||||||
fp = buf + dirlen;
|
fp = buf + dirlen;
|
||||||
if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) &&
|
if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) &&
|
||||||
(d = opendir(buf))) {
|
(d = opendir(buf))) {
|
||||||
|
|
Loading…
Reference in New Issue