mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-06 13:20:57 +03:00
gssapi: Add missing malloc checks
Fixes T141 Reported-By: Ramin Farajpour Cami Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
@@ -328,7 +328,10 @@ static char *ssh_gssapi_name_to_char(gss_name_t name){
|
|||||||
"converting name",
|
"converting name",
|
||||||
maj_stat,
|
maj_stat,
|
||||||
min_stat);
|
min_stat);
|
||||||
ptr=malloc(buffer.length + 1);
|
ptr = malloc(buffer.length + 1);
|
||||||
|
if (ptr == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
memcpy(ptr, buffer.value, buffer.length);
|
memcpy(ptr, buffer.value, buffer.length);
|
||||||
ptr[buffer.length] = '\0';
|
ptr[buffer.length] = '\0';
|
||||||
gss_release_buffer(&min_stat, &buffer);
|
gss_release_buffer(&min_stat, &buffer);
|
||||||
@@ -794,6 +797,10 @@ static gss_OID ssh_gssapi_oid_from_string(ssh_string oid_s){
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret->elements = malloc(len - 2);
|
ret->elements = malloc(len - 2);
|
||||||
|
if (ret->elements == NULL) {
|
||||||
|
SAFE_FREE(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
memcpy(ret->elements, &data[2], len-2);
|
memcpy(ret->elements, &data[2], len-2);
|
||||||
ret->length = len-2;
|
ret->length = len-2;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user