[CRIU] [PATCH] restore: don't BUG_ON() if inet address image size is wrong

Kinsbursky Stanislav skinsbursky at openvz.org
Mon Aug 13 09:16:08 EDT 2012


From: Stanislav Kinsbursky <skinsbursky at openvz.org>

This aptch replaces BUG_ON's by return of error code.

Signed-off-by: Stanislav Kinsbursky <skinsbursky at openvz.org>
---
 sk-inet.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
-------------- next part --------------
diff --git a/sk-inet.c b/sk-inet.c
index d5266ad..454d2c5 100644
--- a/sk-inet.c
+++ b/sk-inet.c
@@ -425,11 +425,19 @@ int inet_bind(int sk, struct inet_sk_info *ii)
 
 	memzero(&addr, sizeof(addr));
 	if (ii->ie->family == AF_INET) {
+		if (pb_repeated_size(ii->ie, src_addr) < sizeof(addr.v4.sin_addr.s_addr)) {
+			pr_perror("IPv4 source address dump size is to small");
+			return -1;
+		}
 		addr.v4.sin_family = ii->ie->family;
 		addr.v4.sin_port = htons(ii->ie->src_port);
 		memcpy(&addr.v4.sin_addr.s_addr, ii->ie->src_addr, sizeof(addr.v4.sin_addr.s_addr));
 		addr_size = sizeof(addr.v4);
 	} else if (ii->ie->family == AF_INET6) {
+		if (pb_repeated_size(ii->ie, src_addr) < sizeof(addr.v6.sin6_addr.s6_addr)) {
+			pr_perror("IPv6 source address dump size is to small");
+			return -1;
+		}
 		addr.v6.sin6_family = ii->ie->family;
 		addr.v6.sin6_port = htons(ii->ie->src_port);
 		memcpy(&addr.v6.sin6_addr.s6_addr, ii->ie->src_addr, sizeof(addr.v6.sin6_addr.s6_addr));
@@ -458,11 +466,19 @@ int inet_connect(int sk, struct inet_sk_info *ii)
 
 	memzero(&addr, sizeof(addr));
 	if (ii->ie->family == AF_INET) {
+		if (pb_repeated_size(ii->ie, dst_addr) < sizeof(addr.v4.sin_addr.s_addr)) {
+			pr_perror("IPv4 destination address dump size is to small");
+			return -1;
+		}
 		addr.v4.sin_family = ii->ie->family;
 		addr.v4.sin_port = htons(ii->ie->dst_port);
 		memcpy(&addr.v4.sin_addr.s_addr, ii->ie->dst_addr, sizeof(addr.v4.sin_addr.s_addr));
 		addr_size = sizeof(addr.v4);
 	} else if (ii->ie->family == AF_INET6) {
+		if (pb_repeated_size(ii->ie, dst_addr) < sizeof(addr.v6.sin6_addr.s6_addr)) {
+			pr_perror("IPv6 destination address dump size is to small");
+			return -1;
+		}
 		addr.v6.sin6_family = ii->ie->family;
 		addr.v6.sin6_port = htons(ii->ie->dst_port);
 		memcpy(&addr.v6.sin6_addr.s6_addr, ii->ie->dst_addr, sizeof(addr.v6.sin6_addr.s6_addr));


More information about the CRIU mailing list