Index: /trunk/Ohana/src/libfits/header/F_read_H.c
===================================================================
--- /trunk/Ohana/src/libfits/header/F_read_H.c	(revision 15750)
+++ /trunk/Ohana/src/libfits/header/F_read_H.c	(revision 15751)
@@ -35,11 +35,11 @@
 		    sizeof(char), FT_RECORD_SIZE, f);
     if (Nbytes != FT_RECORD_SIZE) {
+      if (feof(f)) return (FALSE);
       perror ("fits read error");
+      return (FALSE);
     }
     
     header[0].size += Nbytes;
-    if (Nbytes != FT_RECORD_SIZE) {
-      return (FALSE);
-    }
+
     if (i == 0) { 
       /* on first block, verify it is a FITS table: SIMPLE .. or XTENSION ... */
Index: /trunk/Ohana/src/libfits/include/gfitsio.h
===================================================================
--- /trunk/Ohana/src/libfits/include/gfitsio.h	(revision 15750)
+++ /trunk/Ohana/src/libfits/include/gfitsio.h	(revision 15751)
@@ -128,4 +128,5 @@
 int     gfits_write_header             PROTO((char *filename, Header *header)); 
 int     gfits_data_size                PROTO((Header *header));
+int     gfits_data_min_size            PROTO((Header *header));
 int 	gfits_extended_to_primary      PROTO((Header *header, int simple, char *comment));
 int 	gfits_primary_to_extended      PROTO((Header *header, char *exttype, char *comment));
Index: /trunk/Ohana/src/libfits/matrix/F_load_M.c
===================================================================
--- /trunk/Ohana/src/libfits/matrix/F_load_M.c	(revision 15750)
+++ /trunk/Ohana/src/libfits/matrix/F_load_M.c	(revision 15751)
@@ -31,5 +31,10 @@
   nbytes = fread (matrix[0].buffer, sizeof(char), Nbytes, f);
   if (nbytes != Nbytes) {
-    perror ("fits matrix read error");
+    perror ("FITS file is short in ##__func__");
+    if (nbytes != gfits_data_min_size (header)) {
+      fprintf (stderr, "error: fits read error in %s", __func__);
+      return (FALSE);
+    }
+    fprintf (stderr, "warning: file missing pad\n");
   }
 
Index: /trunk/Ohana/src/libfits/matrix/F_matrix.c
===================================================================
--- /trunk/Ohana/src/libfits/matrix/F_matrix.c	(revision 15750)
+++ /trunk/Ohana/src/libfits/matrix/F_matrix.c	(revision 15751)
@@ -24,2 +24,19 @@
   return (size);
 }
+
+int gfits_data_min_size (Header *header) {
+  
+  int i, size;
+
+  if (header[0].Naxes == 0) return (0);
+
+  size = abs(header[0].bitpix / 8);
+
+  for (i = 0; i < header[0].Naxes; i++)
+    size *= header[0].Naxis[i];
+
+  // XXX do I multiply this times gcount?
+  size += header[0].pcount;
+
+  return (size);
+}
Index: /trunk/Ohana/src/libfits/table/F_read_T.c
===================================================================
--- /trunk/Ohana/src/libfits/table/F_read_T.c	(revision 15750)
+++ /trunk/Ohana/src/libfits/table/F_read_T.c	(revision 15751)
@@ -52,4 +52,5 @@
 
   int Nbytes, Nread;
+  char string[128];
 
   /* find buffer size */
@@ -59,7 +60,12 @@
   Nread = fread (table[0].buffer, sizeof (char), Nbytes, f);
   if (Nread != Nbytes) {
-    perror ("fits read error");
-    gfits_free_table  (table);
-    return (FALSE);
+    snprintf (string, 128, "FITS file is short (%s)", __func__);
+    perror (string);
+    if (Nread < gfits_data_min_size (table[0].header)) {
+      fprintf (stderr, "error: fits read error in %s, read %d, need %d\n", __func__, Nread, gfits_data_min_size (table[0].header));
+      gfits_free_table  (table);
+      return (FALSE);
+    }
+    fprintf (stderr, "warning: file missing pad\n");
   }
   table[0].size = Nbytes;
