1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
$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) {
|