diff options
Diffstat (limited to 'misc-utils/namei.c')
-rw-r--r-- | misc-utils/namei.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/misc-utils/namei.c b/misc-utils/namei.c index 783c5b9b6..60ec98a93 100644 --- a/misc-utils/namei.c +++ b/misc-utils/namei.c @@ -98,7 +98,9 @@ main(int argc, char **argv) { } if(getcwd(curdir, sizeof(curdir)) == NULL){ - (void)fprintf(stderr, _("namei: unable to get current directory - %s\n"), curdir); + (void)fprintf(stderr, + _("namei: unable to get current directory - %s\n"), + curdir); exit(1); } @@ -109,7 +111,9 @@ main(int argc, char **argv) { namei(argv[optind], 0); if(chdir(curdir) == -1){ - (void)fprintf(stderr, _("namei: unable to chdir to %s - %s (%d)\n"), curdir, ERR); + (void)fprintf(stderr, + _("namei: unable to chdir to %s - %s (%d)\n"), + curdir, ERR); exit(1); } } @@ -163,6 +167,11 @@ namei(char *file, int lev) { for(;;){ + if (strlen(file) >= BUFSIZ) { + fprintf(stderr,_("namei: buf overflow\n")); + return; + } + /* * Copy up to the next / (or nil) into buf */ @@ -228,7 +237,7 @@ namei(char *file, int lev) { case S_IFLNK: /* - * Sigh, another symlink. Read it's contents and + * Sigh, another symlink. Read its contents and * call namei() */ |