diff options
author | 2003-05-13 16:55:22 +0000 | |
---|---|---|
committer | 2003-05-13 16:55:22 +0000 | |
commit | 4d12baba14f57b12b1669537e4c62861dcc403bc (patch) | |
tree | e18b1c375d9ee6eb49f991a5a1f4ab43b620ce63 | |
parent | Add support for blocking thread switches during dlopen and other (diff) | |
download | wireguard-openbsd-4d12baba14f57b12b1669537e4c62861dcc403bc.tar.xz wireguard-openbsd-4d12baba14f57b12b1669537e4c62861dcc403bc.zip |
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.
-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); |