diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-05-13 16:55:23 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-05-13 16:55:23 +0000 |
commit | 6735c1febb9177dbe161d4eac757ba9f0caf3080 (patch) | |
tree | 1be8992722e500492e2be42de31f7fa877541e68 /usr.bin/lndir/lndir.c | |
parent | 09633e9f98f50e906a012742b2b61b29ecdd406c (diff) |
Use dp->d_namlen instead of strlen(dp->d_name) and check for
dp->d_namlen == 0. Shouldn't be possible but the check prevents
any possibilty of using an array index of -1.
Diffstat (limited to 'usr.bin/lndir/lndir.c')
-rw-r--r-- | usr.bin/lndir/lndir.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/usr.bin/lndir/lndir.c b/usr.bin/lndir/lndir.c index 2fb6c6bf21c..53ef05ec7ce 100644 --- a/usr.bin/lndir/lndir.c +++ b/usr.bin/lndir/lndir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lndir.c,v 1.13 2003/04/14 03:14:06 millert Exp $ */ +/* $OpenBSD: lndir.c,v 1.14 2003/05/13 16:55:22 millert Exp $ */ /* $XConsortium: lndir.c /main/15 1995/08/30 10:56:18 gildea $ */ /* @@ -207,11 +207,10 @@ dodir(char *fn, struct stat *fs, struct stat *ts, int rel) *p++ = '/'; n_dirs = fs->st_nlink; while ((dp = readdir(df))) { - if (dp->d_name[strlen(dp->d_name) - 1] == '~') + if (dp->d_namlen == 0 || dp->d_name[dp->d_namlen - 1] == '~') continue; - for (cur = exceptions; cur != (struct except *)NULL; - cur = cur->next) { - if (!strcmp (dp->d_name, cur->name)) + for (cur = exceptions; cur != NULL; cur = cur->next) { + if (!strcmp(dp->d_name, cur->name)) goto next; /* can't continue */ } strlcpy(p, dp->d_name, buf + sizeof(buf) - p); |