X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fiso2709.c;h=f583f062330a91de973fe87a01dfd1df99d6a48f;hb=7b58e36bc4c5a57dec46408bbfb3707638dd967a;hp=54c32cd24ad8542dd82c945687d33edf278c37a4;hpb=5d2b04d154ff79a61b09f26fff4e60ca95ef4792;p=egate.git diff --git a/util/iso2709.c b/util/iso2709.c index 54c32cd..f583f06 100644 --- a/util/iso2709.c +++ b/util/iso2709.c @@ -1,10 +1,64 @@ /* + * Copyright (c) 1995, the EUROPAGATE consortium (see below). + * + * The EUROPAGATE consortium members are: + * + * University College Dublin + * Danmarks Teknologiske Videnscenter + * An Chomhairle Leabharlanna + * Consejo Superior de Investigaciones Cientificas + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation, in whole or in part, for any purpose, is hereby granted, + * provided that: + * + * 1. This copyright and permission notice appear in all copies of the + * software and its documentation. Notices of copyright or attribution + * which appear at the beginning of any file must remain unchanged. + * + * 2. The names of EUROPAGATE or the project partners may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * 3. Users of this software (implementors and gateway operators) agree to + * inform the EUROPAGATE consortium of their use of the software. This + * information will be used to evaluate the EUROPAGATE project and the + * software, and to plan further developments. The consortium may use + * the information in later publications. + * + * 4. Users of this software agree to make their best efforts, when + * documenting their use of the software, to acknowledge the EUROPAGATE + * consortium, and the role played by the software in their work. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * IN NO EVENT SHALL THE EUROPAGATE CONSORTIUM OR ITS MEMBERS BE LIABLE + * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF + * ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA + * OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND + * ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE + * USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +/* * Iso2709 record management * * Europagate, 1994-1995. * * $Log: iso2709.c,v $ - * Revision 1.14 1995/03/30 14:22:18 adam + * Revision 1.17 1995/12/20 16:28:08 adam + * Extra parameter block to gw_db_open. If block is 0 gw_db_open + * returns NULL if lock couldn't be satisfied. + * Minor changes in iso2709.c. + * + * Revision 1.16 1995/05/16 09:40:53 adam + * LICENSE. + * + * Revision 1.15 1995/03/31 10:42:41 adam + * Bug fix. + * + * Revision 1.14 1995/03/30 14:22:18 adam * More work on new MARC anchor functions. * * Revision 1.13 1995/03/30 07:33:32 adam @@ -171,6 +225,7 @@ Iso2709Rec iso2709_cvt (const char *buf) } (*dpp)->next = NULL; (*dpp)->fields = NULL; + (*dpp)->indicator = NULL; strncpyx ((*dpp)->tag, buf+pos, 3); pos += 3; (*dpp)->length = atoin (buf+pos, p->length_data_entry); @@ -194,6 +249,11 @@ Iso2709Rec iso2709_cvt (const char *buf) int dpos = pos+dp->offset; int epos = pos+dp->offset+dp->length-1; + if (epos <= dpos) + { + iso2709_rm (p); + return NULL; + } fpp = &dp->fields; if (!(*fpp = malloc (sizeof(**fpp)))) @@ -206,7 +266,7 @@ Iso2709Rec iso2709_cvt (const char *buf) identifier_flag = 1; if (p->indicator_length) { -#if STUPID_ISO_DBC +#if WEIRD_ISO_DBC if (buf[dpos+p->indicator_length] != ISO2709_IDFS) identifier_flag = 0; #else @@ -256,7 +316,7 @@ Iso2709Rec iso2709_cvt (const char *buf) strncpyx ((*fpp)->data, buf+dpos, dpos_n - dpos); dpos = dpos_n; - if (dpos == epos) + if (dpos >= epos) { if (buf[dpos] != ISO2709_FS && buf[dpos] != ISO2709_RS) fprintf (stderr, "Missing separator at end of field "