[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: [PATCH] gssapi: detect malloc failure


malloc(n) returns NULL on failure.
malloc(0) may return NULL.

Patch:

Author: raminfp <ramin.blackhat@xxxxxxxxx>
Date:   Wed Mar 20 20:56:33 2019 +0000

   malloc will return NULL

diff --git a/src/gssapi.c b/src/gssapi.c
index f2ca38df..a30b5590 100644
--- a/src/gssapi.c
+++ b/src/gssapi.c
@@ -328,7 +328,9 @@ static char *ssh_gssapi_name_to_char(gss_name_t name){
                         "converting name",
                         maj_stat,
                         min_stat);
-    ptr=malloc(buffer.length + 1);
+    ptr = malloc(buffer.length + 1);
+    if(ptr == NULL)
+       return NULL;
    memcpy(ptr, buffer.value, buffer.length);
    ptr[buffer.length] = '\0';
    gss_release_buffer(&min_stat, &buffer);

-- 
Ramin Farajpour Cami

Archive administrator: postmaster@lists.cynapses.org