From: Adam Dickmeiss Date: Thu, 15 Jan 2009 12:06:06 +0000 (+0100) Subject: ISO2709 decoding: skip control characters from indicator data X-Git-Tag: v3.0.42~13 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=4a23f09ebdcc59ef94e50d385cc5b17f42d8845d;ds=sidebyside ISO2709 decoding: skip control characters from indicator data ISO2709 indicators that hold control characters are marked invalid and the control characters are now skipped. --- diff --git a/src/marc_read_iso2709.c b/src/marc_read_iso2709.c index 89839ea..249ba42 100644 --- a/src/marc_read_iso2709.c +++ b/src/marc_read_iso2709.c @@ -149,8 +149,23 @@ int yaz_marc_read_iso2709(yaz_marc_t mt, const char *buf, int bsize) { /* datafield */ i += identifier_flag-1; - yaz_marc_add_datafield(mt, tag, buf+i, indicator_length); - i += indicator_length; + if (indicator_length) + { + /* skip RS/FS bytes in indicator. They are not allowed there */ + int j; + for (j = indicator_length; --j >= 0; ) + if (buf[j+i] < ' ') + { + j++; + i += j; + end_offset += j; + yaz_marc_cprintf(mt, "Bad indicator data. " + "Skipping %d bytes", j); + break; + } + yaz_marc_add_datafield(mt, tag, buf+i, indicator_length); + i += indicator_length; + } while (i < end_offset && buf[i] != ISO2709_RS && buf[i] != ISO2709_FS) @@ -182,7 +197,7 @@ int yaz_marc_read_iso2709(yaz_marc_t mt, const char *buf, int bsize) if (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS) { yaz_marc_cprintf(mt, "No separator at end of field length=%d", - data_length); + data_length); } } return record_length;