X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=data1%2Fd1_expout.c;h=ce0a5e3ba889be1d621fe192994b376343ac35ae;hb=44621b084e8fdf06a45409754116e8810bd89664;hp=3757f284c5cb5e7250db80520a6a823447b3cba8;hpb=1872e3fc60b482771bbd1cb4b0290b8d6a9ef5d0;p=idzebra-moved-to-github.git diff --git a/data1/d1_expout.c b/data1/d1_expout.c index 3757f28..ce0a5e3 100644 --- a/data1/d1_expout.c +++ b/data1/d1_expout.c @@ -1,8 +1,5 @@ -/* $Id: d1_expout.c,v 1.10 2007-04-16 08:44:31 adam Exp $ - Copyright (C) 1995-2007 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1994-2010 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -71,18 +68,15 @@ static int is_data_tag (ExpHandle *eh, data1_node *c) return 1; } -static int *f_integer(ExpHandle *eh, data1_node *c) +static Odr_int *f_integer(ExpHandle *eh, data1_node *c) { - int *r; char intbuf[64]; c = c->child; - if (!is_data_tag (eh, c) || c->u.data.len > 63) + if (!is_data_tag (eh, c) || c->u.data.len >= sizeof(intbuf)) return 0; - r = (int *)odr_malloc(eh->o, sizeof(*r)); sprintf(intbuf, "%.*s", c->u.data.len, c->u.data.data); - *r = atoi(intbuf); - return r; + return odr_intdup(eh->o, atoi(intbuf)); } static char *f_string(ExpHandle *eh, data1_node *c) @@ -187,7 +181,7 @@ Odr_oid **f_oid_seq (ExpHandle *eh, data1_node *n, int *num, oid_class oclass) ++(*num); if (!*num) return NULL; - res = (int **)odr_malloc (eh->o, sizeof(*res) * (*num)); + res = (Odr_oid **)odr_malloc (eh->o, sizeof(*res) * (*num)); for (c = n->child, i = 0 ; c; c = c->next) if (is_numeric_tag (eh, c) == 1000) res[i++] = f_oid (eh, c, oclass); @@ -254,7 +248,7 @@ Z_RpnCapabilities *f_rpnCapabilities (ExpHandle *eh, data1_node *n) (res->num_operators)++; } if (res->num_operators) - res->operators = (int **) + res->operators = (Odr_int **) odr_malloc (eh->o, res->num_operators * sizeof(*res->operators)); for (n = c->child; n; n = n->next) @@ -391,9 +385,8 @@ static Z_AccessInfo *f_accessInfo(ExpHandle *eh, data1_node *n) return res; } -static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which) +static Odr_int *f_recordCount(ExpHandle *eh, data1_node *c, int *which) { - int *r= (int *)odr_malloc(eh->o, sizeof(*r)); int *wp = which; char intbuf[64]; @@ -406,11 +399,11 @@ static int *f_recordCount(ExpHandle *eh, data1_node *c, int *which) *wp = Z_DatabaseInfo_approxNumber; else return 0; - if (!c->child || c->child->which != DATA1N_data) + if (!c->child || c->child->which != DATA1N_data || + c->child->u.data.len >= sizeof(intbuf)) return 0; sprintf(intbuf, "%.*s", c->child->u.data.len, c->child->u.data.data); - *r = atoi(intbuf); - return r; + return odr_intdup(eh->o, atoi(intbuf)); } static Z_ContactInfo *f_contactInfo(ExpHandle *eh, data1_node *n) @@ -1407,6 +1400,7 @@ Z_ExplainRecord *data1_nodetoexplain (data1_handle dh, data1_node *n, /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab