(grow_descr): increment the size after we succeed to allocate the space
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12617 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -547,21 +547,23 @@ grow_descr (struct descr *d, size_t n)
|
|||||||
{
|
{
|
||||||
if (d->size - d->len < n) {
|
if (d->size - d->len < n) {
|
||||||
unsigned char *tmp;
|
unsigned char *tmp;
|
||||||
|
size_t grow;
|
||||||
|
|
||||||
d->size += max(1024, d->len + n);
|
grow = max(1024, d->len + n);
|
||||||
if (d->size >= max_request) {
|
if (d->size + grow > max_request) {
|
||||||
kdc_log(0, "Request exceeds max request size (%lu bytes).",
|
kdc_log(0, "Request exceeds max request size (%lu bytes).",
|
||||||
(unsigned long)d->size);
|
(unsigned long)d->size + grow);
|
||||||
clear_descr(d);
|
clear_descr(d);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tmp = realloc (d->buf, d->size);
|
tmp = realloc (d->buf, d->size + grow);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
kdc_log(0, "Failed to re-allocate %lu bytes.",
|
kdc_log(0, "Failed to re-allocate %lu bytes.",
|
||||||
(unsigned long)d->size);
|
(unsigned long)d->size + grow);
|
||||||
clear_descr(d);
|
clear_descr(d);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
d->size += grow;
|
||||||
d->buf = tmp;
|
d->buf = tmp;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user