about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-10-14 02:12:35 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-10-14 02:12:35 +0000
commit7983661603923b2e2af43fd4d0c6e6b93f7970a6 (patch)
tree4b2eb14edf366cfa1d888687edb7cde53be5aa8a
parent0d782c278caeb9e70b1a5635d018168b09ecf2ba (diff)
downloadnetpbm-mirror-7983661603923b2e2af43fd4d0c6e6b93f7970a6.tar.gz
netpbm-mirror-7983661603923b2e2af43fd4d0c6e6b93f7970a6.tar.xz
netpbm-mirror-7983661603923b2e2af43fd4d0c6e6b93f7970a6.zip
Release 11.00.01
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4448 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/other/fitstopnm.c20
-rw-r--r--doc/HISTORY5
-rw-r--r--version.mk2
3 files changed, 21 insertions, 6 deletions
diff --git a/converter/other/fitstopnm.c b/converter/other/fitstopnm.c
index 82c19a69..804d4ae9 100644
--- a/converter/other/fitstopnm.c
+++ b/converter/other/fitstopnm.c
@@ -355,7 +355,7 @@ readCard(FILE * const ifP,
     size_t bytesRead;
 
     bytesRead = fread(buf, 1, 80, ifP);
-    if (bytesRead == 0)
+    if (bytesRead < 80)
         pm_error("error reading header");
 }
 
@@ -394,8 +394,10 @@ static void
 readFitsHeader(FILE *               const ifP,
                struct FITS_Header * const hP) {
 
-    bool gotSimple, gotNaxis, gotN1, gotN2, gotN3, gotBitpix, gotEnd;
 
+    bool gotEmpty, gotSimple, gotNaxis, gotN1, gotN2, gotN3, gotBitpix, gotEnd;
+
+    gotEmpty  = false;  /* initial value */    
     gotSimple = false;  /* initial value */
     gotNaxis  = false;  /* initial value */
     gotN1     = false;  /* initial value */
@@ -412,14 +414,19 @@ readFitsHeader(FILE *               const ifP,
 
     while (!gotEnd) {
         unsigned int i;
+
         for (i = 0; i < 36; ++i) {
-            char buf[80];
+            char buf[81];
             char c;
             int n;
 
-            readCard(ifP, buf);
+            readCard(ifP, buf); /* Reads into first 80 elements of buf[] */
+
+            buf[80] = '\0'; /* Make ASCIIZ string */
 
-            if (sscanf(buf, "SIMPLE = %c", &c) == 1) {
+            if (sscanf(buf, " %c", &c) < 1) {
+                gotEmpty = true;
+            } else if (sscanf(buf, "SIMPLE = %c", &c) == 1) {
                 if (gotSimple)
                     pm_error("FITS header has two SIMPLE keywords");
                 gotSimple = true;
@@ -454,6 +461,9 @@ readFitsHeader(FILE *               const ifP,
             } else if (sscanf(buf, "BSCALE = %lf", &(hP->bscale)) == 1) {
             } else if (strncmp(buf, "END ", 4 ) == 0) {
                 gotEnd = true;
+                if (gotEmpty == true)
+                    pm_message("Blank card(s) were encountered before "
+			       "END in header");
             }
         }
     }
diff --git a/doc/HISTORY b/doc/HISTORY
index 54c9150d..f320d1c4 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -4,6 +4,11 @@ Netpbm.
 CHANGE HISTORY 
 --------------
 
+22.10.14 BJH  Release 11.00.01
+
+              fitstopnm: fix invalid memory reference (nonterminated ASCIIZ
+              string).
+
 22.09.28 BJH  Release 11.00.00
 
               (No significance to new major number; just ran out of 2-digit
diff --git a/version.mk b/version.mk
index 1f56bf78..410b22e7 100644
--- a/version.mk
+++ b/version.mk
@@ -1,3 +1,3 @@
 NETPBM_MAJOR_RELEASE = 11
 NETPBM_MINOR_RELEASE = 0
-NETPBM_POINT_RELEASE = 0
+NETPBM_POINT_RELEASE = 1