diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2006-01-30 10:32:19 +0000 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2006-01-30 10:32:19 +0000 |
commit | 45c1ba772efd16c845f81b0bfb68a842124ba203 (patch) | |
tree | 92f25abf357442bc686616c05b08e115b2af8f9a /lib | |
parent | 17a623cd837dfa63508e3ef49235a522189b6917 (diff) | |
download | quilt-45c1ba772efd16c845f81b0bfb68a842124ba203.tar.gz |
- lib/backup-files.c: Tru64 does not have snprintf. (Reported by
John Vandenberg).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/backup-files.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/backup-files.c b/lib/backup-files.c index a551ac3..d2979d0 100644 --- a/lib/backup-files.c +++ b/lib/backup-files.c @@ -384,22 +384,20 @@ foreachdir_rec(const char *path, struct stat *st, DIR *dir; struct dirent *dp; int failed = 0; - char *p = malloc_nofail(PATH_MAX + 1); + char *p = malloc_nofail(PATH_MAX); if (access(path, R_OK|X_OK) || !(dir = opendir(path))) return walk(path, NULL); while ((dp = readdir(dir))) { - int len; - if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) continue; - len = snprintf(p, PATH_MAX + 1, "%s/%s", path, dp->d_name); - if (len > PATH_MAX || len < 0) { + if (strlen(path) + 1 + strlen(dp->d_name) + 1 > PATH_MAX) { fprintf(stderr, "%s/%s: name too long\n", path, dp->d_name); failed = -1; goto out; } + sprintf(p, "%s/%s", path, dp->d_name); if (lstat(p, st)) continue; /* file has disappeared meanwhile */ |