diff options
author | jilles <jilles@FreeBSD.org> | 2011-12-28 23:30:17 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2011-12-28 23:30:17 +0000 |
commit | f9224784391f6d5bc219e7779fa000ba9a68963b (patch) | |
tree | 251e19c505f000a164128a322cb10ae12362ab1b | |
parent | 4b4e03aec0d7f0c6cb2aea32d60176814567d049 (diff) | |
download | FreeBSD-src-f9224784391f6d5bc219e7779fa000ba9a68963b.zip FreeBSD-src-f9224784391f6d5bc219e7779fa000ba9a68963b.tar.gz |
sh: Cache de->d_namlen in a local variable.
-rw-r--r-- | bin/sh/expand.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/bin/sh/expand.c b/bin/sh/expand.c index ea8d78d..df05a9a 100644 --- a/bin/sh/expand.c +++ b/bin/sh/expand.c @@ -1186,6 +1186,7 @@ expmeta(char *enddir, char *name) int atend; int matchdot; int esc; + int namlen; metaflag = 0; start = name; @@ -1284,17 +1285,18 @@ expmeta(char *enddir, char *name) if (dp->d_name[0] == '.' && ! matchdot) continue; if (patmatch(start, dp->d_name, 0)) { - if (enddir + dp->d_namlen + 1 > expdir_end) + namlen = dp->d_namlen; + if (enddir + namlen + 1 > expdir_end) continue; - memcpy(enddir, dp->d_name, dp->d_namlen + 1); + memcpy(enddir, dp->d_name, namlen + 1); if (atend) addfname(expdir); else { - if (enddir + dp->d_namlen + 2 > expdir_end) + if (enddir + namlen + 2 > expdir_end) continue; - enddir[dp->d_namlen] = '/'; - enddir[dp->d_namlen + 1] = '\0'; - expmeta(enddir + dp->d_namlen + 1, endname); + enddir[namlen] = '/'; + enddir[namlen + 1] = '\0'; + expmeta(enddir + namlen + 1, endname); } } } |