/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2011 Index Data
+ * Copyright (C) 1995-2013 Index Data
* See the file LICENSE for details.
*/
yaz_marc_reset(mt);
- record_length = atoi_n (buf, 5);
+ if (!atoi_n_check(buf, 5, &record_length))
+ {
+ yaz_marc_cprintf(mt, "Bad leader");
+ return -1;
+ }
if (record_length < 25)
{
yaz_marc_cprintf(mt, "Record length %d < 24", record_length);
{
WRBUF hex = wrbuf_alloc();
/* Not all digits, so stop directory scan */
- wrbuf_write_escaped(hex, buf + entry_p,
+ wrbuf_write_escaped(hex, buf + entry_p,
length_data_entry + length_starting + 3);
yaz_marc_cprintf(mt, "Directory offset %d: Bad value for data"
" length and/or length starting (%s)", entry_p,
if (data_length <= 0 || data_offset < 0)
break;
-
+
if (yaz_marc_get_debug(mt))
{
yaz_marc_cprintf(mt, "Tag: %s. Directory offset %d: data-length %d,"
entry_p0, end_offset, record_length);
break;
}
-
+
if (memcmp (tag, "00", 2))
identifier_flag = 1; /* if not 00X assume subfields */
else if (indicator_length < 4 && indicator_length > 0)
{
/* controlfield */
int i0 = i;
- while (i < end_offset &&
+ while (i < end_offset &&
buf[i] != ISO2709_RS && buf[i] != ISO2709_FS)
i++;
yaz_marc_add_controlfield(mt, tag, buf+i0, i-i0);