From 7aaf40e9f9c2d200f5a9c8bee646c0741b9cea49 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Mon, 26 Mar 2007 16:20:43 -0500 Subject: [svn-r13546] Bug fix The H5TB_find_field function was not correctly finding a string field name amongst a string list of parameters of field names in cases where the name is similar up to n characters. Solution: added an extra verify condition with the string length Tested: kagiso, simple fix --- hl/src/H5TB.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/hl/src/H5TB.c b/hl/src/H5TB.c index 1e055da..8f9eb07 100644 --- a/hl/src/H5TB.c +++ b/hl/src/H5TB.c @@ -3457,18 +3457,22 @@ out: static int H5TB_find_field( const char *field, const char *field_list ) { - const char *start = field_list; - const char *end; - - while ( (end = strstr( start, "," )) != 0 ) { - if ( strncmp(start,field,(size_t)(end-start)) == 0 ) return 1; - start = end + 1; - } - - if ( strcmp( start, field ) == 0 ) return 1; - - return -1; - + const char *start = field_list; + const char *end; + + while ( (end = strstr( start, "," )) != 0 ) + { + size_t count = end - start; + if ( strncmp(start, field, count) == 0 && count == strlen(field) ) + return 1; + start = end + 1; + } + + if ( strcmp( start, field ) == 0 ) + return 1; + + return -1; + } -- cgit v0.12