summaryrefslogtreecommitdiff
path: root/devel/cscope/patches/patch-ah
blob: 632a3640e75b503bcebd0220a1479dd9e09860fd (plain)
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
67
68
69
70
71
72
73
74
75
$NetBSD: patch-ah,v 1.4.2.1 2006/08/25 11:05:02 ghen Exp $

--- src/dir.c.orig	2003-06-02 12:43:00.000000000 +0200
+++ src/dir.c	2006-08-24 23:34:52.000000000 +0200
@@ -138,7 +138,7 @@ sourcedir(char *dirlist)
 			
 			/* 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 @@ includedir(char *dirlist)
 			
 			/* 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);
@@ -319,7 +319,7 @@ makefilelist(void)
 			
 			/* Parse whitespace-terminated strings in line: */
 			point_in_line = line;
-			while (sscanf(point_in_line, "%s", path) == 1) {
+			while (sscanf(point_in_line, "%" PATHLEN_STR "s", path) == 1) {
 				/* Have to store this length --- inviewpath() will
 				 * modify path, later! */
 				length_of_name = strlen(path);
@@ -474,8 +474,6 @@ scan_dir(const char *adir, BOOL recurse_
 	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 @@ scan_dir(const char *adir, BOOL recurse_
 			    && (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 @@ incfile(char *file, char *type)
 		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 @@ inviewpath(char *file)
 
 		/* 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) {