RADIUS: Fix a possible memory leak on an error path
authorAyala Beker <ayala.beker@intel.com>
Thu, 7 Apr 2016 10:31:00 +0000 (13:31 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 8 Apr 2016 08:40:20 +0000 (11:40 +0300)
Fix a possible memory leak in radius_msg_add_mppe_keys() if
os_get_random() fails.

Signed-off-by: Ayala Beker <ayala.beker@intel.com>
src/radius/radius.c

index da978db..7bc6f74 100644 (file)
@@ -1199,8 +1199,10 @@ int radius_msg_add_mppe_keys(struct radius_msg *msg,
        vhdr = (struct radius_attr_vendor *) pos;
        vhdr->vendor_type = RADIUS_VENDOR_ATTR_MS_MPPE_SEND_KEY;
        pos = (u8 *) (vhdr + 1);
-       if (os_get_random((u8 *) &salt, sizeof(salt)) < 0)
+       if (os_get_random((u8 *) &salt, sizeof(salt)) < 0) {
+               os_free(buf);
                return 0;
+       }
        salt |= 0x8000;
        WPA_PUT_BE16(pos, salt);
        pos += 2;