about summary refs log tree commit diff
path: root/converter/pgm
diff options
context:
space:
mode:
Diffstat (limited to 'converter/pgm')
-rw-r--r--converter/pgm/sbigtopgm.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/converter/pgm/sbigtopgm.c b/converter/pgm/sbigtopgm.c
index bb3cb6fe..e57e26e8 100644
--- a/converter/pgm/sbigtopgm.c
+++ b/converter/pgm/sbigtopgm.c
@@ -61,7 +61,7 @@ int main(argc, argv)
     register int col;
     int maxval;
     int comp, rows, cols;
-    char header[SBIG_HEADER_LENGTH];
+    char header[SBIG_HEADER_LENGTH+1];
     char *hdr;
     static char camera[80] = "ST-?";
 
@@ -82,6 +82,7 @@ int main(argc, argv)
     if (fread(header, SBIG_HEADER_LENGTH, 1, ifp) < 1) {
         pm_error("error reading SBIG file header");
     }
+    header[SBIG_HEADER_LENGTH] = '\0';
 
     /*	Walk through the header and parse relevant parameters.	*/
 
@@ -122,12 +123,13 @@ int main(argc, argv)
             pm_error("malformed SBIG file header at character %d", hdr - header);
 	}
 	*cp = 0;
-        if (strncmp(hdr, "ST-", 3) == 0) {
+        if (strncmp(hdr, "ST-", 3) == 0)  ||
+            (hdr == &hdr[0] && strstr(hdr,"Image") != NULL)) {
             char *ep = strchr(hdr + 3, ' ');
 
 	    if (ep != NULL) {
 		*ep = 0;
-		strcpy(camera, hdr);
+		STRSCPY(camera, hdr);
                 *ep = ' ';
 	    }
 	}