Source-Changes-HG archive

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

[src/trunk]: src/dist/bind/bin/nsupdate There's no use assigning the output o...



details:   https://anonhg.NetBSD.org/src/rev/b550954f384a
branches:  trunk
changeset: 526713:b550954f384a
user:      simonb <simonb%NetBSD.org@localhost>
date:      Thu May 09 03:14:14 2002 +0000

description:
There's no use assigning the output of strtoul() to a 32-bit variable
then checking that against ULONG_MAX.  Instead use a "unsigned long"
as the temporary variable.  Then check against UINT32_MAX before
assigning back to the original variable.

diffstat:

 dist/bind/bin/nsupdate/nsupdate.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (25 lines):

diff -r 6974973bf451 -r b550954f384a dist/bind/bin/nsupdate/nsupdate.c
--- a/dist/bind/bin/nsupdate/nsupdate.c Thu May 09 02:55:49 2002 +0000
+++ b/dist/bind/bin/nsupdate/nsupdate.c Thu May 09 03:14:14 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nsupdate.c,v 1.2 2001/01/27 07:22:02 itojun Exp $      */
+/*     $NetBSD: nsupdate.c,v 1.3 2002/05/09 03:14:14 simonb Exp $      */
 
 #if !defined(lint) && !defined(SABER)
 static const char rcsid[] = "Id: nsupdate.c,v 8.26 2000/12/23 08:14:48 vixie Exp";
@@ -400,11 +400,13 @@
                (void) getword_str(buf2, sizeof buf2, &startp, endp);
 
                if (isdigit(buf2[0])) { /* ttl */
-                   r_ttl = strtoul(buf2, 0, 10);
-                   if (errno == ERANGE && r_ttl == ULONG_MAX) {
+                   u_long tmp_ttl = strtoul(buf2, 0, 10);
+                   if ((errno == ERANGE && tmp_ttl == ULONG_MAX) ||
+                       tmp_ttl > UINT32_MAX) {
                        fprintf(stderr, "oversized ttl: %s\n", buf2);
                        exit (1);
                    }
+                   r_ttl = tmp_ttl;
                    (void) getword_str(buf2, sizeof buf2, &startp, endp);
                }
 



Home | Main Index | Thread Index | Old Index