$NetBSD: patch-ah,v 1.4 2006/05/29 13:51:20 tron Exp $ --- src/dir.c.orig 2003-06-02 11:43:00.000000000 +0100 +++ src/dir.c 2006-05-29 14:34:26.000000000 +0100 @@ -138,7 +138,7 @@ /* compute its path from higher view path source dirs */ for (i = 1; i < nvpsrcdirs; ++i) { - (void) sprintf(path, "%.*s/%s", + (void) snprintf(path, sizeof(path), "%.*s/%s", PATHLEN - 2 - dir_len, srcdirs[i], dir); addsrcdir(path); @@ -206,7 +206,7 @@ /* compute its path from higher view path source dirs */ for (i = 1; i < nvpsrcdirs; ++i) { - (void) sprintf(path, "%.*s/%s", + (void) snprintf(path, sizeof(path), "%.*s/%s", PATHLEN - 2 - dir_len, srcdirs[i], dir); addincdir(dir, path); @@ -474,8 +474,6 @@ DIR *dirfile; int adir_len = strlen(adir); - /* FIXME: no guards against adir_len > PATHLEN, yet */ - if ((dirfile = opendir(adir)) != NULL) { struct dirent *entry; char path[PATHLEN + 1]; @@ -486,7 +484,7 @@ && (strcmp("..",entry->d_name) != 0)) { struct stat buf; - sprintf(path,"%s/%.*s", adir, + snprintf(path, sizeof(path), "%s/%.*s", adir, PATHLEN - 2 - adir_len, entry->d_name); @@ -603,14 +601,14 @@ for (i = 0; i < nincdirs; ++i) { /* don't include the file from two directories */ - (void) sprintf(name, "%.*s/%s", + (void) snprintf(name, sizeof(name), "%.*s/%s", PATHLEN - 2 - file_len, incnames[i], file); if (infilelist(name) == YES) { break; } /* make sure it exists and is readable */ - (void) sprintf(path, "%.*s/%s", + (void) snprintf(path, sizeof(path), "%.*s/%s", PATHLEN - 2 - file_len, incdirs[i], file); if (access(compath(path), READ) == 0) { @@ -654,7 +652,7 @@ /* compute its path from higher view path source dirs */ for (i = 1; i < nvpsrcdirs; ++i) { - (void) sprintf(path, "%.*s/%s", + (void) snprintf(path, sizeof(path), "%.*s/%s", PATHLEN - 2 - file_len, srcdirs[i], file); if (access(compath(path), READ) == 0) {