diff --git a/mspack/cabd.c b/mspack/cabd.c index 16021ee..8b10934 100644 --- a/mspack/cabd.c +++ b/mspack/cabd.c @@ -521,10 +521,13 @@ static char *cabd_read_string(struct mspack_system *sys, { off_t base = sys->tell(fh); char buf[256], *str; - unsigned int len, i, ok; + int len, i, ok; /* read up to 256 bytes */ - len = sys->read(fh, &buf[0], 256); + if ((len = sys->read(fh, &buf[0], 256)) <= 0) { + *error = MSPACK_ERR_READ; + return NULL; + } /* search for a null terminator in the buffer */ for (i = 0, ok = 0; i < len; i++) if (!buf[i]) { ok = 1; break; }