Skip to contentSkip to conversation

clnt_dg_call: Fix a buffer overflow (CVE-2016-4429)

PATCH In review Steve Dickson 1 participant 2 messages Mar 1, 2018 – Mar 2, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clnt_dg_call: Fix a buffer overflow (CVE-2016-4429)

---
 src/clnt_dg.c | 7 +++++++
 1 file changed, 7 insertions(+)
src/clnt_dg.c +7 -0
index 248138b..884a2db 100644
@@ -433,6 +433,11 @@ get_reply:
 	  char *cbuf = (char *) alloca (outlen + 256);
 	  int ret;
 
+	  if (cbuf == NULL) 
+	  {
+	  	cu->cu_error.re_errno = errno;
+		return (cu->cu_error.re_status = RPC_CANTRECV);
+	  }
 	  iov.iov_base = cbuf + 256;
 	  iov.iov_len = outlen;
 	  msg.msg_name = (void *) &err_addr;
@@ -457,11 +462,13 @@ get_reply:
 		 cmsg = CMSG_NXTHDR (&msg, cmsg))
 	      if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR)
 		{
+		  free(cbuf);
 		  e = (struct sock_extended_err *) CMSG_DATA(cmsg);
 		  cu->cu_error.re_errno = e->ee_errno;
 		  release_fd_lock(cu->cu_fd, mask);
 		  return (cu->cu_error.re_status = RPC_CANTRECV);
 		}
+	  free(cbuf);
 	}
 #endif
 
Signature · 1 line
2.14.3
#1 lore raw
Quoted 2 lines · Steve Dickson

Committed...

steved.

Quoted 35 lines
---
 src/clnt_dg.c | 7 +++++++
 1 file changed, 7 insertions(+)
src/clnt_dg.c +7 -0
index 248138b..884a2db 100644
@@ -433,6 +433,11 @@ get_reply:
 	  char *cbuf = (char *) alloca (outlen + 256);
 	  int ret;
 
+	  if (cbuf == NULL) 
+	  {
+	  	cu->cu_error.re_errno = errno;
+		return (cu->cu_error.re_status = RPC_CANTRECV);
+	  }
 	  iov.iov_base = cbuf + 256;
 	  iov.iov_len = outlen;
 	  msg.msg_name = (void *) &err_addr;
@@ -457,11 +462,13 @@ get_reply:
 		 cmsg = CMSG_NXTHDR (&msg, cmsg))
 	      if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR)
 		{
+		  free(cbuf);
 		  e = (struct sock_extended_err *) CMSG_DATA(cmsg);
 		  cu->cu_error.re_errno = e->ee_errno;
 		  release_fd_lock(cu->cu_fd, mask);
 		  return (cu->cu_error.re_status = RPC_CANTRECV);
 		}
+	  free(cbuf);
 	}
 #endif