[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mgp-users 00765] fix: image type check



Magicpoint dumps, if I use an unknown image-type.
Patch attached, can also be applied to the cvs version.

Best,
	Bernhard
ps.: Please send my copies of relevant replies as I am not
subscribed to the list.
pps.: An archive would be helpful.

-- 
Professional Service around Free Software                (intevation.net)  
The FreeGIS Project                                         (freegis.org)
Association for a Free Informational Infrastructure            (ffii.org)
FSF Europe                                            	  (fsfeurope.org)
To fix the core dump because of the unterminated convdb loop.
(The reason for the crash is that NULL is converted to an integer
and then to a value at the first place of the character array.
This is different to a NULL pointer, thus the check for this might fail.)

<bernhard@intevation.de>

--- magicpoint-1.08a/mgp.c.org	Sun Dec 30 22:46:46 2001
+++ magicpoint-1.08a/mgp.c	Sun Dec 30 22:54:55 2001
@@ -440,7 +440,7 @@
 	FILE *txt;
 	int page;
 	char *childdebug;
-	char convdb[][3][16] = {{ "jpg", "cjpeg", "djpeg" },
+	char *(convdb[][3]) = {{ "jpg", "cjpeg", "djpeg" },
 				{ "png", "pnmtopng", "pngtopnm" },
 				{ NULL, NULL, NULL }};
 	int inum = 0;
@@ -452,7 +452,16 @@
 				break;
 		}
 		if (*convdb[inum] == NULL) {
-			fprintf(stderr, "unknwon image type %s.\n", htmlimage);
+			fprintf(stderr, 
+				"Error: Unknown image type %s.\n", htmlimage);
+
+			/* print out valid image types */
+			fprintf(stderr, "Valid image types: ", htmlimage);
+			for (inum = 0; *convdb[inum] != NULL; inum++) {
+				fprintf(stderr, "%s ",*convdb[inum] );
+			}
+			fprintf(stderr,"\n");
+
 			cleanup(-1);
 		}
 	}

Attachment: pgp2xba5KEB7G.pgp
Description: PGP signature