remember to repoint all descr->sa to _ss after realloc as this might
have moved the memory around. problem discovered and diagnosed by Brandon S. Allbery git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8082 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -207,6 +207,19 @@ init_descr(struct descr *d)
|
|||||||
d->s = -1;
|
d->s = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* re-intialize all `n' ->sa in `d'.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
reinit_descrs (struct descr *d, int n)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < n; ++i)
|
||||||
|
d[i].sa = (struct sockaddr *)&d[i].__ss;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create the socket (family, type, port) in `d'
|
* Create the socket (family, type, port) in `d'
|
||||||
*/
|
*/
|
||||||
@@ -318,6 +331,7 @@ init_sockets(struct descr **desc)
|
|||||||
d = realloc(d, num * sizeof(*d));
|
d = realloc(d, num * sizeof(*d));
|
||||||
if (d == NULL && num != 0)
|
if (d == NULL && num != 0)
|
||||||
krb5_errx(context, 1, "realloc(%u) failed", num * sizeof(*d));
|
krb5_errx(context, 1, "realloc(%u) failed", num * sizeof(*d));
|
||||||
|
reinit_descrs (d, num);
|
||||||
*desc = d;
|
*desc = d;
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
@@ -561,7 +575,7 @@ handle_vanilla_tcp (struct descr *d)
|
|||||||
krb5_ret_int32(sp, &len);
|
krb5_ret_int32(sp, &len);
|
||||||
krb5_storage_free(sp);
|
krb5_storage_free(sp);
|
||||||
if(d->len - 4 >= len) {
|
if(d->len - 4 >= len) {
|
||||||
memcpy(d->buf, d->buf + 4, d->len - 4);
|
memmove(d->buf, d->buf + 4, d->len - 4);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -735,8 +749,9 @@ loop(void)
|
|||||||
tmp = realloc(d, (ndescr + 4) * sizeof(*d));
|
tmp = realloc(d, (ndescr + 4) * sizeof(*d));
|
||||||
if(tmp == NULL)
|
if(tmp == NULL)
|
||||||
krb5_warnx(context, "No memory");
|
krb5_warnx(context, "No memory");
|
||||||
else{
|
else {
|
||||||
d = tmp;
|
d = tmp;
|
||||||
|
reinit_descrs (d, ndescr);
|
||||||
memset(d + ndescr, 0, 4 * sizeof(*d));
|
memset(d + ndescr, 0, 4 * sizeof(*d));
|
||||||
for(i = ndescr; i < ndescr + 4; i++)
|
for(i = ndescr; i < ndescr + 4; i++)
|
||||||
init_descr (&d[i]);
|
init_descr (&d[i]);
|
||||||
|
Reference in New Issue
Block a user