Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd fix incorrect overflow test: https://android-re...



details:   https://anonhg.NetBSD.org/src/rev/1f3281effab8
branches:  trunk
changeset: 327407:1f3281effab8
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Mar 07 01:04:29 2014 +0000

description:
fix incorrect overflow test: https://android-review.googlesource.com/#/c/50570/

diffstat:

 external/bsd/dhcp/dist/common/ns_name.c     |  9 +++++----
 external/bsd/libbind/dist/nameser/ns_name.c |  8 +++++---
 2 files changed, 10 insertions(+), 7 deletions(-)

diffs (58 lines):

diff -r bdd687730397 -r 1f3281effab8 external/bsd/dhcp/dist/common/ns_name.c
--- a/external/bsd/dhcp/dist/common/ns_name.c   Fri Mar 07 01:00:58 2014 +0000
+++ b/external/bsd/dhcp/dist/common/ns_name.c   Fri Mar 07 01:04:29 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ns_name.c,v 1.4 2013/03/27 00:38:08 christos Exp $     */
+/*     $NetBSD: ns_name.c,v 1.5 2014/03/07 01:04:29 christos Exp $     */
 
 /*
  * Copyright (c) 2004,2009 by Internet Systems Consortium, Inc. ("ISC")
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: ns_name.c,v 1.4 2013/03/27 00:38:08 christos Exp $");
+__RCSID("$NetBSD: ns_name.c,v 1.5 2014/03/07 01:04:29 christos Exp $");
 
 #ifndef lint
 static const char rcsid[] = "Id: ns_name.c,v 1.2 2009/10/28 04:12:29 sar Exp ";
@@ -344,11 +344,12 @@
                        }
                        if (len < 0)
                                len = srcp - src + 1;
-                       srcp = msg + (((n & 0x3f) << 8) | (*srcp & 0xff));
-                       if (srcp < msg || srcp >= eom) {  /* Out of range. */
+                       n = ((n & 0x3f) << 8) | (*srcp & 0xff);
+                       if (n >= eom - msg) {  / Out of range. */
                                errno = EMSGSIZE;
                                return (-1);
                        }
+                       srcp = msg + n;
                        checked += 2;
                        /*
                         * Check for loops in the compressed name;
diff -r bdd687730397 -r 1f3281effab8 external/bsd/libbind/dist/nameser/ns_name.c
--- a/external/bsd/libbind/dist/nameser/ns_name.c       Fri Mar 07 01:00:58 2014 +0000
+++ b/external/bsd/libbind/dist/nameser/ns_name.c       Fri Mar 07 01:04:29 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ns_name.c,v 1.1.1.2 2012/09/09 16:08:04 christos Exp $ */
+/*     $NetBSD: ns_name.c,v 1.2 2014/03/07 01:06:07 christos Exp $     */
 
 /*
  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
@@ -463,11 +463,13 @@
                        }
                        if (len < 0)
                                len = srcp - src + 1;
-                       srcp = msg + (((n & 0x3f) << 8) | (*srcp & 0xff));
-                       if (srcp < msg || srcp >= eom) {  /*%< Out of range. */
+
+                       n = ((n & 0x3f) << 8) | (*srcp & 0xff);
+                       if (n >= eom - msg) {  /*%< Out of range. */
                                errno = EMSGSIZE;
                                return (-1);
                        }
+                       srcp = msg + n;
                        checked += 2;
                        /*
                         * Check for loops in the compressed name;



Home | Main Index | Thread Index | Old Index