[PATCH] cipso: subtraction on unsigned hdr_delta

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Roel Kluin
Date: Tuesday, March 3, 2009 - 3:23 pm

hdr_delta is unsigned, so take care not to subtract below 0.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 7bc9929..b1d862b 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -1999,7 +1999,11 @@ void cipso_v4_sock_delattr(struct sock *sk)
 				iter++;
 		hdr_delta = opt->optlen;
 		opt->optlen = (optlen_new + 3) & ~3;
-		hdr_delta -= opt->optlen;
+
+		if (hdr_delta > opt->optlen)
+			hdr_delta -= opt->optlen;
+		else
+			hdr_delta = 0;
 	} else {
 		/* only the cipso option was present on the socket so we can
 		 * remove the entire option struct */
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] cipso: subtraction on unsigned hdr_delta, Roel Kluin, (Tue Mar 3, 3:23 pm)
Re: [PATCH] cipso: subtraction on unsigned hdr_delta, David Miller, (Wed Mar 4, 12:42 am)
Re: [PATCH] cipso: subtraction on unsigned hdr_delta, Paul Moore, (Wed Mar 4, 10:25 am)