libixp

git clone git://oldgit.suckless.org/libixp/
Log | Files | Refs | LICENSE

commit f46e453181e8fe692a9cca3ab627cef4a235f6af
parent 987a91e33db45ad761eeb8cc7a219b37e9294ed9
Author: Kris Maglione <jg@suckless.org>
Date:   Sun, 18 Mar 2007 01:56:09 -0400

Allocate enough space for terminating nuls when unpacking strings.

Diffstat:
convert.c | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/convert.c b/convert.c @@ -100,13 +100,15 @@ ixp_unpack_strings(uchar **msg, int *msize, ushort n, char **strings) { size = *msize; s = *msg; - for(i=0; i<n; i++) { + for(i=0; i<n && size > 0; i++) { ixp_unpack_u16(&s, &size, &len); s += len; size -= len; } - if((size <= 0) - || (size = *msize - size) == 0) { + if(size < 0) + size = 0; + size = *msize - size + n; + if(size <= 0) { /* So we don't try to free some random value */ *strings = NULL; return;