Browse Source

Fixed potential NULL pointer dereference if memory allocation fails

Jouni Malinen 17 years ago
parent
commit
7cdeb81e1f
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/eap_server/eap_tls_common.c

+ 6 - 0
src/eap_server/eap_tls_common.c

@@ -114,6 +114,10 @@ struct wpabuf * eap_server_tls_build_msg(struct eap_ssl_data *data,
 	size_t send_len, plen;
 
 	wpa_printf(MSG_DEBUG, "SSL: Generating Request");
+	if (data->out_buf == NULL) {
+		wpa_printf(MSG_ERROR, "SSL: out_buf NULL in %s", __func__);
+		return NULL;
+	}
 
 	flags = version;
 	send_len = wpabuf_len(data->out_buf) - data->out_used;
@@ -342,6 +346,8 @@ struct wpabuf * eap_server_tls_encrypt(struct eap_sm *sm,
 	/* reserve some extra room for encryption overhead */
 	buf_len = plain_len + 200;
 	buf = wpabuf_alloc(buf_len);
+	if (buf == NULL)
+		return NULL;
 	res = tls_connection_encrypt(sm->ssl_ctx, data->conn,
 				     plain, plain_len, wpabuf_put(buf, 0),
 				     buf_len);