Mercurial > code
comparison buffer.c @ 4:e19a50d6a5be
Fix security if using bad flags
author | David Demelier <markand@malikania.fr> |
---|---|
date | Tue, 06 Sep 2011 18:55:19 +0200 |
parents | 22d7bb03e569 |
children | 0ed27735fa87 |
comparison
equal
deleted
inserted
replaced
3:9ee89108528b | 4:e19a50d6a5be |
---|---|
240 while (buf->size - buf->length - 1 < needed) | 240 while (buf->size - buf->length - 1 < needed) |
241 buf->size += buf->bsize; | 241 buf->size += buf->bsize; |
242 | 242 |
243 if (!(buf->data = realloc(buf->data, buf->size))) | 243 if (!(buf->data = realloc(buf->data, buf->size))) |
244 return -1; | 244 return -1; |
245 } else if ((buf->flags & BUFFER_FIXED)) | 245 } else |
246 return (buf->bsize == buf->length) ? -1 : 0; | 246 return (buf->bsize == buf->length) ? -1 : 0; |
247 | 247 |
248 memset(buf->data + buf->length, 0, buf->size - buf->length); | 248 memset(buf->data + buf->length, 0, buf->size - buf->length); |
249 | 249 |
250 return 0; | 250 return 0; |