]> granicus.if.org Git - postgis/commitdiff
Make sure input is at least 3 characters long (#1146)
authorSandro Santilli <strk@keybit.net>
Mon, 19 Dec 2011 16:19:07 +0000 (16:19 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 19 Dec 2011 16:19:07 +0000 (16:19 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8471 b70326c6-7e19-0410-871a-916f4a2858ee

doc/html/image_src/generator.c

index 3d09403f5b4ceef08738e2738a868ad2f2f7ff7d..82be408fbb63664f0b36edc65a2460dc4841984a 100644 (file)
@@ -338,12 +338,13 @@ int main( int argc, const char* argv[] )
        int layerCount;
        int styleNumber;
        LAYERSTYLE *styles;
+       char *image_path = "../images/";
 
        getStyles(&styles);
 
-       if ( argc != 2 )
+       if ( argc != 2 || strlen(argv[1]) < 3)
        {
-               lwerror("You must specifiy a wkt filename to convert.\n");
+               lwerror("You must specify a wkt filename to convert, and it must be 3 or more characters long.\n");
                return -1;
        }
 
@@ -353,8 +354,8 @@ int main( int argc, const char* argv[] )
                return -1;
        }
 
-       filename = malloc( strlen(argv[1])+11 );
-       strcpy( filename, "../images/" );
+       filename = malloc( strlen(argv[1]) + strlen(image_path) + 1 );
+       strcpy( filename, image_path );
        strncat( filename, argv[1], strlen(argv[1])-3 );
        strncat( filename, "png", 3 );