X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fmarc_read_iso2709.c;h=07cd59a7c9db0015e2716de2fe68671a865c3666;hp=cf3f0aa115819681a9a3b5befe860016ae5ad91c;hb=4efb9de61a4284830d3dde10a992a42067879c84;hpb=8d691989077a0addcbd840d769dce6700f3d9622 diff --git a/src/marc_read_iso2709.c b/src/marc_read_iso2709.c index cf3f0aa..07cd59a 100644 --- a/src/marc_read_iso2709.c +++ b/src/marc_read_iso2709.c @@ -1,8 +1,6 @@ -/* - * Copyright (C) 1995-2007, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2009 Index Data * See the file LICENSE for details. - * - * $Id: marc_read_iso2709.c,v 1.2 2007-01-03 08:42:15 adam Exp $ */ /** @@ -151,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) @@ -184,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; @@ -193,6 +206,7 @@ int yaz_marc_read_iso2709(yaz_marc_t mt, const char *buf, int bsize) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab