summaryrefslogtreecommitdiff
path: root/media-gfx/xli/files/xli-security-gentoo.diff
blob: 7425e67c7c74a3b3744350b21c9196c1b67fa674 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
diff -Nrup xli-2005-02-27/imagetypes.c xli-2005-02-27/imagetypes.c
--- xli-2005-02-27/imagetypes.c	1999-10-24 22:14:57.000000000 -0400
+++ xli-2005-02-27/imagetypes.c	2005-10-18 07:53:46.000000000 -0400
@@ -53,7 +53,7 @@ Image *loadImage(ImageOptions * image_op
 	Image *image;
 	int a;
 
-	if (findImage(image_ops->name, fullname) < 0) {
+	if (findImage(image_ops->name, fullname, BUFSIZ) < 0) {
 		if (errno == ENOENT)
 			printf("%s: image not found\n", image_ops->name);
 		else if (errno == EISDIR)
@@ -95,7 +95,7 @@ void identifyImage(char *name)
 	char fullname[BUFSIZ];
 	int a;
 
-	if (findImage(name, fullname) < 0) {
+	if (findImage(name, fullname, BUFSIZ) < 0) {
 		if (errno == ENOENT)
 			printf("%s: image not found\n", name);
 		else if (errno == EISDIR)
diff -Nrup xli-2005-02-27/path.c xli-2005-02-27/path.c
--- xli-2005-02-27/path.c	2005-02-27 19:42:39.000000000 -0500
+++ xli-2005-02-27/path.c	2005-10-18 07:56:45.000000000 -0400
@@ -172,12 +172,12 @@ static int fileIsOk(char *fullname, stru
 /* find an image with paths and extensions from defaults files.  returns
  * -1 if access denied or not found, 0 if ok.
  */
-int findImage(char *name, char *fullname)
+int findImage(char *name, char *fullname, size_t size)
 {
 	unsigned int p, e;
 	struct stat sbuf;
 
-	strcpy(fullname, name);
+	strncpy(fullname, name, size);
 	if (!strcmp(name, "stdin"))	/* stdin is special name */
 		return (0);
 
@@ -185,26 +185,26 @@ int findImage(char *name, char *fullname
 	if (!stat(fullname, &sbuf))
 		return (fileIsOk(fullname, &sbuf));
 #ifndef NO_COMPRESS
-	strcat(fullname, ".Z");
+	strncat(fullname, ".Z", size);
 	if (!stat(fullname, &sbuf))
 		return (fileIsOk(fullname, &sbuf));
 #endif
 
 	for (p = 0; p < NumPaths; p++) {
-		sprintf(fullname, "%s/%s", Paths[p], name);
+		snprintf(fullname, size, "%s/%s", Paths[p], name);
 		if (!stat(fullname, &sbuf))
 			return (fileIsOk(fullname, &sbuf));
 #ifndef NO_COMPRESS
-		strcat(fullname, ".Z");
+		strncat(fullname, ".Z", size);
 		if (!stat(fullname, &sbuf))
 #endif
 			return (fileIsOk(fullname, &sbuf));
 		for (e = 0; e < NumExts; e++) {
-			sprintf(fullname, "%s/%s%s", Paths[p], name, Exts[e]);
+			snprintf(fullname, size, "%s/%s%s", Paths[p], name, Exts[e]);
 			if (!stat(fullname, &sbuf))
 				return (fileIsOk(fullname, &sbuf));
 #ifndef NO_COMPRESS
-			strcat(fullname, ".Z");
+			strncat(fullname, ".Z", size);
 			if (!stat(fullname, &sbuf))
 				return (fileIsOk(fullname, &sbuf));
 #endif
@@ -212,11 +212,11 @@ int findImage(char *name, char *fullname
 	}
 
 	for (e = 0; e < NumExts; e++) {
-		sprintf(fullname, "%s%s", name, Exts[e]);
+		snprintf(fullname, size, "%s%s", name, Exts[e]);
 		if (!stat(fullname, &sbuf))
 			return (fileIsOk(fullname, &sbuf));
 #ifndef NO_COMPRESS
-		strcat(fullname, ".Z");
+		strncat(fullname, ".Z", size);
 		if (!stat(fullname, &sbuf))
 			return (fileIsOk(fullname, &sbuf));
 #endif
@@ -241,7 +241,7 @@ void listImages(void)
 	for (a = 0; a < NumPaths; a++) {
 		printf("%s:\n", Paths[a]);
 		fflush(stdout);
-		sprintf(buf, "ls %s", Paths[a]);
+		snprintf(buf, sizeof(buf)-1, "ls %s", Paths[a]);
 		if (system(buf) < 0) {
 			perror("ls");
 			return;
@@ -296,14 +296,14 @@ char *expandPath(char *p)
 			var++;
 		else if (*p == '~') {
 			buf1[b1] = '\0';
-			strcat(buf1, getenv("HOME"));
+			strncat(buf1, getenv("HOME"), sizeof(buf1)-1);
 			b1 = strlen(buf1);
 			var = 0;
 		} else if (*p == '/' || *p == '}') {
 			if (var) {
 				buf1[b1] = '\0';
 				buf2[b2] = '\0';
-				strcat(buf1, getenv(buf2));
+				strncat(buf1, getenv(buf2), sizeof(buf1));
 				b1 = strlen(buf1);
 				buf2[0] = '\0';
 				b2 = 0;
diff -Nrup xli-2005-02-27/reduce.c xli-2005-02-27/reduce.c
--- xli-2005-02-27/reduce.c	1999-10-24 22:15:02.000000000 -0400
+++ xli-2005-02-27/reduce.c	2005-10-18 07:33:34.000000000 -0400
@@ -178,7 +178,7 @@ Image *reduce(Image *image, unsigned col
 	/* get destination image */
 	depth = colorsToDepth(OutColors);
 	new_image = newRGBImage(image->width, image->height, depth);
-	sprintf(buf, "%s (%d colors)", image->title, OutColors);
+	snprintf(buf, sizeof(buf)-1, "%s (%d colors)", image->title, OutColors);
 	new_image->title = dupString(buf);
 	new_image->gamma = image->gamma;
 
diff -Nrup xli-2005-02-27/rlelib.c xli-2005-02-27/rlelib.c
--- xli-2005-02-27/rlelib.c	2005-10-18 07:40:51.000000000 -0400
+++ xli-2005-02-27/rlelib.c	2005-10-18 07:48:12.000000000 -0400
@@ -18,7 +18,7 @@
 #undef  DEBUG
 
 #ifdef DEBUG
-# define debug(xx)	fprintf(stderr,xx)
+# define debug(xx)	fprintf(stderr, "%s", xx)
 #else
 # define debug(xx)
 #endif
Files xli-2005-02-27/xli and xli-2005-02-27/xli differ
diff -Nrup xli-2005-02-27/xli.h xli-2005-02-27/xli.h
--- xli-2005-02-27/xli.h	1999-10-24 22:15:07.000000000 -0400
+++ xli-2005-02-27/xli.h	2005-10-19 07:49:21.000000000 -0400
@@ -229,7 +229,7 @@ char *xlistrstr(char *s1, char *s2);
 
 /* path.c */
 char *expandPath(char *p);
-int findImage(char *name, char *fullname);
+int findImage(char *name, char *fullname, size_t size);
 void listImages(void);
 void loadPathsAndExts(void);
 void showPath(void);
diff -Nrup xli-2005-02-27/xlito.c xli-2005-02-27/xlito.c
--- xli-2005-02-27/xlito.c	2005-02-27 19:42:39.000000000 -0500
+++ xli-2005-02-27/xlito.c	2005-10-18 07:48:54.000000000 -0400
@@ -31,7 +31,7 @@ char *pname, *fname;
 #undef  DEBUG
 
 #ifdef DEBUG
-# define debug(xx)	fprintf(stderr,xx)
+# define debug(xx)	fprintf(stderr, "%s", xx)
 #else
 # define debug(xx)
 #endif
diff -Nrup xli-2005-02-27/zoom.c xli-2005-02-27/zoom.c
--- xli-2005-02-27/zoom.c	2005-02-27 19:42:39.000000000 -0500
+++ xli-2005-02-27/zoom.c	2005-10-18 07:35:42.000000000 -0400
@@ -52,30 +52,30 @@ Image *zoom(Image *oimage, unsigned int 
     if (verbose)
       printf("  Zooming image Y axis by %d%%...", yzoom);
     if (changetitle)
-      sprintf(buf, "%s (Y zoom %d%%)", oimage->title, yzoom);
+      snprintf(buf, sizeof(buf)-1, "%s (Y zoom %d%%)", oimage->title, yzoom);
   }
   else if (!yzoom) {
     if (verbose)
       printf("  Zooming image X axis by %d%%...", xzoom);
     if (changetitle)
-      sprintf(buf, "%s (X zoom %d%%)", oimage->title, xzoom);
+      snprintf(buf, sizeof(buf)-1, "%s (X zoom %d%%)", oimage->title, xzoom);
   }
   else if (xzoom == yzoom) {
     if (verbose)
       printf("  Zooming image by %d%%...", xzoom);
     if (changetitle)
-      sprintf(buf, "%s (%d%% zoom)", oimage->title, xzoom);
+      snprintf(buf, sizeof(buf)-1, "%s (%d%% zoom)", oimage->title, xzoom);
   }
   else {
     if (verbose)
       printf("  Zooming image X axis by %d%% and Y axis by %d%%...",
 	     xzoom, yzoom);
     if (changetitle)
-      sprintf(buf, "%s (X zoom %d%% Y zoom %d%%)", oimage->title,
+      snprintf(buf, sizeof(buf)-1, "%s (X zoom %d%% Y zoom %d%%)", oimage->title,
 	    xzoom, yzoom);
   }
   if (!changetitle)
-    strcpy(buf,oimage->title);
+    strncpy(buf,oimage->title, sizeof(buf)-1);
 
   if (verbose)
     fflush(stdout);