From: Marc Cromme Date: Thu, 16 Nov 2006 21:58:54 +0000 (+0000) Subject: protected wrong buffer-length write by initializing to 0, but there is more debugging... X-Git-Tag: ZEBRA.2.0.6~39 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=bf647b34fd7224275cb2c1020925897f0d28fe01;p=idzebra-moved-to-github.git protected wrong buffer-length write by initializing to 0, but there is more debugging needed: there is still something fishy with the last out-commented test of test/api/t16.c. --- diff --git a/index/retrieve.c b/index/retrieve.c index eebc808..a9bda9e 100644 --- a/index/retrieve.c +++ b/index/retrieve.c @@ -1,4 +1,4 @@ -/* $Id: retrieve.c,v 1.52 2006-11-16 11:10:46 adam Exp $ +/* $Id: retrieve.c,v 1.53 2006-11-16 21:58:54 marc Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -123,6 +123,9 @@ int zebra_special_index_fetch(ZebraHandle zh, SYSNO sysno, ODR odr, WRBUF wrbuf = 0; zebra_rec_keys_t keys; + /* set output variables before processing possible error states */ + *rec_lenp = 0; + /* only accept XML and SUTRS requests */ if (input_format != VAL_TEXT_XML && input_format != VAL_SUTRS){ @@ -241,7 +244,6 @@ int zebra_special_index_fetch(ZebraHandle zh, SYSNO sysno, ODR odr, if (input_format == VAL_TEXT_XML) wrbuf_printf(wrbuf, "\n"); } - *rec_lenp = wrbuf_len(wrbuf); *rec_bufp = odr_malloc(odr, *rec_lenp); memcpy(*rec_bufp, wrbuf_buf(wrbuf), *rec_lenp); @@ -258,6 +260,9 @@ int zebra_special_fetch(ZebraHandle zh, SYSNO sysno, ODR odr, char **rec_bufp, int *rec_lenp) { Record rec; + + /* set output variables before processing possible error states */ + *rec_lenp = 0; /* only accept XML and SUTRS requests */ if (input_format != VAL_TEXT_XML diff --git a/test/api/t16.c b/test/api/t16.c index 563b267..4ace1e5 100644 --- a/test/api/t16.c +++ b/test/api/t16.c @@ -1,4 +1,4 @@ -/* $Id: t16.c,v 1.2 2006-11-16 20:44:28 marc Exp $ +/* $Id: t16.c,v 1.3 2006-11-16 21:58:55 marc Exp $ Copyright (C) 1995-2006 Index Data ApS