Commit 45f36932 authored by Evan Hunt's avatar Evan Hunt
Browse files

[master] check malloc/calloc return values

3436.	[bug]		Check malloc/calloc return values. [RT #32088]
parent 5b1fe44f
3436. [bug] Check malloc/calloc return values. [RT #32088]
3435. [bug] Cross compilation support in configure was broken.
[RT #32078]
......
......@@ -430,6 +430,10 @@ add(int rdclass, const char *classname, int type, const char *typename,
return;
newcc = (struct cc *)malloc(sizeof(*newcc));
if (newcc == NULL) {
fprintf(stderr, "malloc() failed\n");
exit(1);
}
newcc->rdclass = rdclass;
strncpy(newcc->classname, classname, TYPECLASSLEN);
cc = classes;
......
......@@ -1553,6 +1553,11 @@ spnego_initial(OM_uint32 *minor_status,
buf_size = 1024;
buf = malloc(buf_size);
if (buf == NULL) {
*minor_status = ENOMEM;
ret = GSS_S_FAILURE;
goto end;
}
do {
ret = encode_NegTokenInit(buf + buf_size - 1,
......
......@@ -269,8 +269,14 @@ decode_MechTypeList(const unsigned char *p, size_t len, MechTypeList * data, siz
(data)->len = 0;
(data)->val = NULL;
while (ret < origlen) {
void *old = (data)->val;
(data)->len++;
(data)->val = realloc((data)->val, sizeof(*((data)->val)) * (data)->len);
if ((data)->val == NULL) {
(data)->val = old;
(data)->len--;
return ENOMEM;
}
e = decode_MechType(p, len, &(data)->val[(data)->len - 1], &l);
FORW;
len = origlen - ret;
......
......@@ -1119,6 +1119,8 @@ hostfromname(lwres_gabnresponse_t *name, int af) {
* Copy aliases.
*/
he->h_aliases = malloc(sizeof(char *) * (name->naliases + 1));
if (he->h_aliases == NULL)
goto cleanup;
for (i = 0; i < name->naliases; i++) {
he->h_aliases[i] = strdup(name->aliases[i]);
if (he->h_aliases[i] == NULL)
......@@ -1130,6 +1132,8 @@ hostfromname(lwres_gabnresponse_t *name, int af) {
* Copy addresses.
*/
he->h_addr_list = malloc(sizeof(char *) * (name->naddrs + 1));
if (he->h_addr_list == NULL)
goto cleanup;
addr = LWRES_LIST_HEAD(name->addrs);
i = 0;
while (addr != NULL) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment