Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 108365 | Differences between
and this patch

Collapse All | Expand All

(-)xli-2005-02-27/imagetypes.c (-2 / +2 lines)
Lines 53-59 Image *loadImage(ImageOptions * image_op Link Here
53
	Image *image;
53
	Image *image;
54
	int a;
54
	int a;
55
55
56
	if (findImage(image_ops->name, fullname) < 0) {
56
	if (findImage(image_ops->name, fullname, BUFSIZ) < 0) {
57
		if (errno == ENOENT)
57
		if (errno == ENOENT)
58
			printf("%s: image not found\n", image_ops->name);
58
			printf("%s: image not found\n", image_ops->name);
59
		else if (errno == EISDIR)
59
		else if (errno == EISDIR)
Lines 95-101 void identifyImage(char *name) Link Here
95
	char fullname[BUFSIZ];
95
	char fullname[BUFSIZ];
96
	int a;
96
	int a;
97
97
98
	if (findImage(name, fullname) < 0) {
98
	if (findImage(name, fullname, BUFSIZ) < 0) {
99
		if (errno == ENOENT)
99
		if (errno == ENOENT)
100
			printf("%s: image not found\n", name);
100
			printf("%s: image not found\n", name);
101
		else if (errno == EISDIR)
101
		else if (errno == EISDIR)
(-)xli-2005-02-27/path.c (-12 / +12 lines)
Lines 172-183 static int fileIsOk(char *fullname, stru Link Here
172
/* find an image with paths and extensions from defaults files.  returns
172
/* find an image with paths and extensions from defaults files.  returns
173
 * -1 if access denied or not found, 0 if ok.
173
 * -1 if access denied or not found, 0 if ok.
174
 */
174
 */
175
int findImage(char *name, char *fullname)
175
int findImage(char *name, char *fullname, size_t size)
176
{
176
{
177
	unsigned int p, e;
177
	unsigned int p, e;
178
	struct stat sbuf;
178
	struct stat sbuf;
179
179
180
	strcpy(fullname, name);
180
	strncpy(fullname, name, size);
181
	if (!strcmp(name, "stdin"))	/* stdin is special name */
181
	if (!strcmp(name, "stdin"))	/* stdin is special name */
182
		return (0);
182
		return (0);
183
183
Lines 185-210 int findImage(char *name, char *fullname Link Here
185
	if (!stat(fullname, &sbuf))
185
	if (!stat(fullname, &sbuf))
186
		return (fileIsOk(fullname, &sbuf));
186
		return (fileIsOk(fullname, &sbuf));
187
#ifndef NO_COMPRESS
187
#ifndef NO_COMPRESS
188
	strcat(fullname, ".Z");
188
	strncat(fullname, ".Z", size);
189
	if (!stat(fullname, &sbuf))
189
	if (!stat(fullname, &sbuf))
190
		return (fileIsOk(fullname, &sbuf));
190
		return (fileIsOk(fullname, &sbuf));
191
#endif
191
#endif
192
192
193
	for (p = 0; p < NumPaths; p++) {
193
	for (p = 0; p < NumPaths; p++) {
194
		sprintf(fullname, "%s/%s", Paths[p], name);
194
		snprintf(fullname, size, "%s/%s", Paths[p], name);
195
		if (!stat(fullname, &sbuf))
195
		if (!stat(fullname, &sbuf))
196
			return (fileIsOk(fullname, &sbuf));
196
			return (fileIsOk(fullname, &sbuf));
197
#ifndef NO_COMPRESS
197
#ifndef NO_COMPRESS
198
		strcat(fullname, ".Z");
198
		strncat(fullname, ".Z", size);
199
		if (!stat(fullname, &sbuf))
199
		if (!stat(fullname, &sbuf))
200
#endif
200
#endif
201
			return (fileIsOk(fullname, &sbuf));
201
			return (fileIsOk(fullname, &sbuf));
202
		for (e = 0; e < NumExts; e++) {
202
		for (e = 0; e < NumExts; e++) {
203
			sprintf(fullname, "%s/%s%s", Paths[p], name, Exts[e]);
203
			snprintf(fullname, size, "%s/%s%s", Paths[p], name, Exts[e]);
204
			if (!stat(fullname, &sbuf))
204
			if (!stat(fullname, &sbuf))
205
				return (fileIsOk(fullname, &sbuf));
205
				return (fileIsOk(fullname, &sbuf));
206
#ifndef NO_COMPRESS
206
#ifndef NO_COMPRESS
207
			strcat(fullname, ".Z");
207
			strncat(fullname, ".Z", size);
208
			if (!stat(fullname, &sbuf))
208
			if (!stat(fullname, &sbuf))
209
				return (fileIsOk(fullname, &sbuf));
209
				return (fileIsOk(fullname, &sbuf));
210
#endif
210
#endif
Lines 212-222 int findImage(char *name, char *fullname Link Here
212
	}
212
	}
213
213
214
	for (e = 0; e < NumExts; e++) {
214
	for (e = 0; e < NumExts; e++) {
215
		sprintf(fullname, "%s%s", name, Exts[e]);
215
		snprintf(fullname, size, "%s%s", name, Exts[e]);
216
		if (!stat(fullname, &sbuf))
216
		if (!stat(fullname, &sbuf))
217
			return (fileIsOk(fullname, &sbuf));
217
			return (fileIsOk(fullname, &sbuf));
218
#ifndef NO_COMPRESS
218
#ifndef NO_COMPRESS
219
		strcat(fullname, ".Z");
219
		strncat(fullname, ".Z", size);
220
		if (!stat(fullname, &sbuf))
220
		if (!stat(fullname, &sbuf))
221
			return (fileIsOk(fullname, &sbuf));
221
			return (fileIsOk(fullname, &sbuf));
222
#endif
222
#endif
Lines 241-247 void listImages(void) Link Here
241
	for (a = 0; a < NumPaths; a++) {
241
	for (a = 0; a < NumPaths; a++) {
242
		printf("%s:\n", Paths[a]);
242
		printf("%s:\n", Paths[a]);
243
		fflush(stdout);
243
		fflush(stdout);
244
		sprintf(buf, "ls %s", Paths[a]);
244
		snprintf(buf, sizeof(buf)-1, "ls %s", Paths[a]);
245
		if (system(buf) < 0) {
245
		if (system(buf) < 0) {
246
			perror("ls");
246
			perror("ls");
247
			return;
247
			return;
Lines 296-309 char *expandPath(char *p) Link Here
296
			var++;
296
			var++;
297
		else if (*p == '~') {
297
		else if (*p == '~') {
298
			buf1[b1] = '\0';
298
			buf1[b1] = '\0';
299
			strcat(buf1, getenv("HOME"));
299
			strncat(buf1, getenv("HOME"), sizeof(buf1)-1);
300
			b1 = strlen(buf1);
300
			b1 = strlen(buf1);
301
			var = 0;
301
			var = 0;
302
		} else if (*p == '/' || *p == '}') {
302
		} else if (*p == '/' || *p == '}') {
303
			if (var) {
303
			if (var) {
304
				buf1[b1] = '\0';
304
				buf1[b1] = '\0';
305
				buf2[b2] = '\0';
305
				buf2[b2] = '\0';
306
				strcat(buf1, getenv(buf2));
306
				strncat(buf1, getenv(buf2), sizeof(buf1));
307
				b1 = strlen(buf1);
307
				b1 = strlen(buf1);
308
				buf2[0] = '\0';
308
				buf2[0] = '\0';
309
				b2 = 0;
309
				b2 = 0;
(-)xli-2005-02-27/reduce.c (-1 / +1 lines)
Lines 178-184 Image *reduce(Image *image, unsigned col Link Here
178
	/* get destination image */
178
	/* get destination image */
179
	depth = colorsToDepth(OutColors);
179
	depth = colorsToDepth(OutColors);
180
	new_image = newRGBImage(image->width, image->height, depth);
180
	new_image = newRGBImage(image->width, image->height, depth);
181
	sprintf(buf, "%s (%d colors)", image->title, OutColors);
181
	snprintf(buf, sizeof(buf)-1, "%s (%d colors)", image->title, OutColors);
182
	new_image->title = dupString(buf);
182
	new_image->title = dupString(buf);
183
	new_image->gamma = image->gamma;
183
	new_image->gamma = image->gamma;
184
184
(-)xli-2005-02-27/rlelib.c (-1 / +1 lines)
Lines 18-24 Link Here
18
#undef  DEBUG
18
#undef  DEBUG
19
19
20
#ifdef DEBUG
20
#ifdef DEBUG
21
# define debug(xx)	fprintf(stderr,xx)
21
# define debug(xx)	fprintf(stderr,"%s", xx)
22
#else
22
#else
23
# define debug(xx)
23
# define debug(xx)
24
#endif
24
#endif
(-)xli-2005-02-27/xlito.c (-1 / +1 lines)
Lines 31-37 char *pname, *fname; Link Here
31
#undef  DEBUG
31
#undef  DEBUG
32
32
33
#ifdef DEBUG
33
#ifdef DEBUG
34
# define debug(xx)	fprintf(stderr,xx)
34
# define debug(xx)	fprintf(stderr, "%s", xx)
35
#else
35
#else
36
# define debug(xx)
36
# define debug(xx)
37
#endif
37
#endif
(-)xli-2005-02-27/zoom.c (-5 / +5 lines)
Lines 52-81 Image *zoom(Image *oimage, unsigned int Link Here
52
    if (verbose)
52
    if (verbose)
53
      printf("  Zooming image Y axis by %d%%...", yzoom);
53
      printf("  Zooming image Y axis by %d%%...", yzoom);
54
    if (changetitle)
54
    if (changetitle)
55
      sprintf(buf, "%s (Y zoom %d%%)", oimage->title, yzoom);
55
      snprintf(buf, sizeof(buf)-1, "%s (Y zoom %d%%)", oimage->title, yzoom);
56
  }
56
  }
57
  else if (!yzoom) {
57
  else if (!yzoom) {
58
    if (verbose)
58
    if (verbose)
59
      printf("  Zooming image X axis by %d%%...", xzoom);
59
      printf("  Zooming image X axis by %d%%...", xzoom);
60
    if (changetitle)
60
    if (changetitle)
61
      sprintf(buf, "%s (X zoom %d%%)", oimage->title, xzoom);
61
      snprintf(buf, sizeof(buf)-1, "%s (X zoom %d%%)", oimage->title, xzoom);
62
  }
62
  }
63
  else if (xzoom == yzoom) {
63
  else if (xzoom == yzoom) {
64
    if (verbose)
64
    if (verbose)
65
      printf("  Zooming image by %d%%...", xzoom);
65
      printf("  Zooming image by %d%%...", xzoom);
66
    if (changetitle)
66
    if (changetitle)
67
      sprintf(buf, "%s (%d%% zoom)", oimage->title, xzoom);
67
      snprintf(buf, sizeof(buf)-1, "%s (%d%% zoom)", oimage->title, xzoom);
68
  }
68
  }
69
  else {
69
  else {
70
    if (verbose)
70
    if (verbose)
71
      printf("  Zooming image X axis by %d%% and Y axis by %d%%...",
71
      printf("  Zooming image X axis by %d%% and Y axis by %d%%...",
72
	     xzoom, yzoom);
72
	     xzoom, yzoom);
73
    if (changetitle)
73
    if (changetitle)
74
      sprintf(buf, "%s (X zoom %d%% Y zoom %d%%)", oimage->title,
74
      snprintf(buf, sizeof(buf)-1, "%s (X zoom %d%% Y zoom %d%%)", oimage->title,
75
	    xzoom, yzoom);
75
	    xzoom, yzoom);
76
  }
76
  }
77
  if (!changetitle)
77
  if (!changetitle)
78
    strcpy(buf,oimage->title);
78
    strncpy(buf,oimage->title, sizeof(buf)-1);
79
79
80
  if (verbose)
80
  if (verbose)
81
    fflush(stdout);
81
    fflush(stdout);

Return to bug 108365