diff options
author | Adam Jackson <ajax@redhat.com> | 2016-04-14 15:56:46 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2017-01-25 14:22:06 -0500 |
commit | cc0f173ea2936d1405e382329c1bd58c7af67ea7 (patch) | |
tree | fc900c80b77bd93983816ff4575c86a7a3c59ed5 | |
parent | 8e83eacb9e2d2c6c2b9f8cdb9e82c976a0237f24 (diff) |
loader: Learn about the joy of snprintf
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
-rw-r--r-- | hw/xfree86/loader/loadmod.c | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c index cb86925b9..ca77c7a9d 100644 --- a/hw/xfree86/loader/loadmod.c +++ b/hw/xfree86/loader/loadmod.c @@ -335,10 +335,7 @@ FindModule(const char *module, const char *dirname, PatternPtr patterns) return NULL; for (s = stdSubdirs; *s; s++) { - if ((strlen(dirname) + strlen(*s)) > PATH_MAX) - continue; - strcpy(buf, dirname); - strcat(buf, *s); + snprintf(buf, PATH_MAX, "%s%s", dirname, *s); if ((name = FindModuleInSubdir(buf, module))) break; } @@ -371,11 +368,7 @@ LoaderListDir(const char *subdir, const char **patternlist) goto bail; for (elem = pathlist; *elem; elem++) { - if ((dirlen = strlen(*elem) + strlen(subdir) + 1) > PATH_MAX) - continue; - strcpy(buf, *elem); - strcat(buf, "/"); - strcat(buf, subdir); + dirlen = snprintf(buf, PATH_MAX, "%s/%s", *elem, subdir); fp = buf + dirlen; if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) && (d = opendir(buf))) { |