diff --git a/ChangeLog b/ChangeLog index 7200a99..c0b212a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-05-10 Stuart Caie <kyzer@4u.net> + + * cabd_read_string(): correct rejection of empty strings. Thanks to + Hanno Böck for finding the issue and providing a sample file. + 2015-01-18 Stuart Caie <kyzer@4u.net> * lzxd_decompress(): the byte-alignment code for reading uncompressed diff --git a/mspack/cabd.c b/mspack/cabd.c index 445750a..16021ee 100644 --- a/mspack/cabd.c +++ b/mspack/cabd.c @@ -526,8 +526,11 @@ static char *cabd_read_string(struct mspack_system *sys, /* read up to 256 bytes */ len = sys->read(fh, &buf[0], 256); - /* search for a null terminator in the buffer. reject empty strings */ - for (i = 1, ok = 0; i < len; i++) if (!buf[i]) { ok = 1; break; } + /* search for a null terminator in the buffer */ + for (i = 0, ok = 0; i < len; i++) if (!buf[i]) { ok = 1; break; } + /* reject empty strings */ + if (i == 0) ok = 0; + if (!ok) { *error = MSPACK_ERR_DATAFORMAT; return NULL;