netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cipso: subtraction on unsigned hdr_delta
@ 2009-03-03 22:23 Roel Kluin
  2009-03-04  7:42 ` David Miller
  2009-03-04 17:25 ` Paul Moore
  0 siblings, 2 replies; 3+ messages in thread
From: Roel Kluin @ 2009-03-03 22:23 UTC (permalink / raw)
  To: paul.moore; +Cc: netdev, David S. Miller, Andrew Morton

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 */

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-03-04 17:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-03 22:23 [PATCH] cipso: subtraction on unsigned hdr_delta Roel Kluin
2009-03-04  7:42 ` David Miller
2009-03-04 17:25 ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).