More robust ISO2709 handling (in case of real bad formats).
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 21 Dec 1999 16:24:48 +0000 (16:24 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 21 Dec 1999 16:24:48 +0000 (16:24 +0000)
client/client.c
util/marcdisp.c

index 13cb16c..a224fcd 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: client.c,v $
- * Revision 1.91  1999-12-16 23:36:19  adam
+ * Revision 1.92  1999-12-21 16:24:48  adam
+ * More robust ISO2709 handling (in case of real bad formats).
+ *
+ * Revision 1.91  1999/12/16 23:36:19  adam
  * Implemented ILL protocol. Minor updates ASN.1 compiler.
  *
  * Revision 1.90  1999/11/30 13:47:11  adam
@@ -753,7 +756,13 @@ static void display_record(Z_DatabaseRecord *p)
             ent->value == VAL_HTML)
             print_record(octet_buf, p->u.octet_aligned->len);
        else
-            marc_display (octet_buf, NULL);
+        {
+            if (marc_display (octet_buf, NULL) <= 0)
+            {
+                printf ("ISO2709 decoding failed, dumping record as is:\n");
+                print_record(octet_buf, p->u.octet_aligned->len);
+            }
+        }
         if (marcdump)
             fwrite (octet_buf, 1, p->u.octet_aligned->len, marcdump);
     }
index 3806681..723026f 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: marcdisp.c,v $
- * Revision 1.8  1999-11-30 13:47:12  adam
+ * Revision 1.9  1999-12-21 16:24:48  adam
+ * More robust ISO2709 handling (in case of real bad formats).
+ *
+ * Revision 1.8  1999/11/30 13:47:12  adam
  * Improved installation. Moved header files to include/yaz.
  *
  * Revision 1.7  1997/09/24 13:29:40  adam
@@ -73,7 +76,11 @@ int marc_display_ex (const char *buf, FILE *outf, int debug)
        fprintf (outf, "Length implementation %5d\n", length_implementation);
     }
     for (entry_p = 24; buf[entry_p] != ISO2709_FS; )
+    {
         entry_p += 3+length_data_entry+length_starting;
+        if (entry_p >= record_length)
+            return -1;
+    }
     base_address = entry_p+1;
     for (entry_p = 24; buf[entry_p] != ISO2709_FS; )
     {