* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: marcdisp.c,v 1.16 2005-02-08 13:51:30 adam Exp $
+ * $Id: marcdisp.c,v 1.17 2005-02-25 09:37:53 adam Exp $
*/
/**
if (entry_p >= record_length)
return -1;
}
- if (mt->debug && base_address != entry_p+1)
+ if (base_address != entry_p+1)
{
if (produce_warnings)
- wrbuf_printf (wr," <!-- base address not at end of directory "
+ wrbuf_printf (wr," <!-- Base address not at end of directory "
"base=%d end=%d -->\n", base_address, entry_p+1);
}
base_address = entry_p+1;
i = data_offset + base_address;
end_offset = i+data_length-1;
- while (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS &&
- i < end_offset)
+ if (data_length <= 0 || data_offset < 0 || end_offset >= record_length)
+ return -1;
+
+ while (i < end_offset &&
+ buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
i++;
sz1 = 1+i - (data_offset + base_address);
if (mt->iconv_cd)
entry_p += length_starting;
i = data_offset + base_address;
end_offset = i+data_length-1;
+
+ if (data_length <= 0 || data_offset < 0 || end_offset >= record_length)
+ {
+ if (produce_warnings)
+ wrbuf_printf (wr," <!-- Bad data-offset=%d or "
+ "data-length=%d -->\n",
+ data_length, data_offset);
+ break;
+ }
if (mt->debug)
{
}
if (identifier_flag)
{
- while (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS && i < end_offset)
+ while (i < end_offset &&
+ buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
{
int i0;
i++;
break;
}
i0 = i;
- while (buf[i] != ISO2709_RS && buf[i] != ISO2709_IDFS &&
- buf[i] != ISO2709_FS && i < end_offset)
+ while (i < end_offset &&
+ buf[i] != ISO2709_RS && buf[i] != ISO2709_IDFS &&
+ buf[i] != ISO2709_FS)
i++;
marc_cdata(mt, buf + i0, i - i0, wr);
else
{
int i0 = i;
- while (buf[i] != ISO2709_RS && buf[i] != ISO2709_FS && i < end_offset)
+ while (i < end_offset &&
+ buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
i++;
marc_cdata(mt, buf + i0, i - i0, wr);
if (mt->xml == YAZ_MARC_ISO2709)
## Copyright (C) 1994-2004, Index Data
## All rights reserved.
-## $Id: Makefile.am,v 1.4 2004-11-03 22:30:52 adam Exp $
+## $Id: Makefile.am,v 1.5 2005-02-25 09:37:53 adam Exp $
check_PROGRAMS = tsticonv tstnmem tstmatchstr tstwrbuf tstodr tstccl tstlog
check_SCRIPTS = tstcql.sh tstmarc.sh
EXTRA_DIST = tstodr.asn tstodrcodec.c tstodrcodec.h cqlsample \
$(check_SCRIPTS) \
- marc1 marc1.xml marc2 marc2.xml marc3 marc3.xml
+ marc1 marc1.xml marc2 marc2.xml marc3 marc3.xml marc4 marc4.xml
YAZCOMP = $(top_srcdir)/util/yaz-asncomp
YAZCOMPLINE = $(YAZCOMP) -d z.tcl -i yaz -I../include $(YCFLAGS)
--- /dev/null
+<!-- Indicator length at offset 10 should hold a digit. Assuming 2 -->
+<!-- Identifier length at offset 11 should hold a digit. Assuming 2 -->
+<!-- Base address at offsets 12..16 should hold a number. Assuming 0 -->
+<!-- Length implementation at offset 22 should hold a digit. Assuming 0 -->
+<record xmlns="http://www.loc.gov/MARC21/slim">
+ <leader>009140091a22a 22003370 </leader>
+ <!-- Base address not at end of directory base=0 end=402 -->
+ <!-- Bad data-offset=0 or data-length=100170 -->
+</record>