Skip to content

Commit

Permalink
Correct rejection of empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
kyz committed May 10, 2015
1 parent f0d26db commit 3e3436a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 7 additions & 2 deletions libmspack/trunk/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-05-10 Stuart Caie <kyzer@4u.net>

* Makefile.am: Add subdir-objects option as suggested by autoreconf.
Expand Down Expand Up @@ -48,7 +53,7 @@
null and thus segfault. Thanks to Jakub Wilk again.

* cabd_read_string: reject empty strings. They are not found in any
valid CAB files. Thanks to Hanno B�ck for sending me an example.
valid CAB files. Thanks to Hanno Böck for sending me an example.

2015-01-05 Stuart Caie <kyzer@4u.net>

Expand Down Expand Up @@ -470,7 +475,7 @@
2005-03-22: Stuart Caie <kyzer@4u.net>

* system.h: now undefs "read", as the latest glibc defines read()
as a macro which messes everything up. Thanks to Ville Skytt� for
as a macro which messes everything up. Thanks to Ville Skyttä for
the update.

2005-03-14: Stuart Caie <kyzer@4u.net>
Expand Down
7 changes: 5 additions & 2 deletions libmspack/trunk/mspack/cabd.c
Expand Up @@ -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;
Expand Down

0 comments on commit 3e3436a

Please sign in to comment.