Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/traceroute Fix possible NULL pointer dereference in...



details:   https://anonhg.NetBSD.org/src/rev/b3d39c3a474b
branches:  trunk
changeset: 760407:b3d39c3a474b
user:      wiz <wiz%NetBSD.org@localhost>
date:      Tue Jan 04 10:26:56 2011 +0000

description:
Fix possible NULL pointer dereference in #ifdef AS_DEBUG_FILE.
Found by cppcheck.

diffstat:

 usr.sbin/traceroute/as.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (26 lines):

diff -r 560cab5cfc85 -r b3d39c3a474b usr.sbin/traceroute/as.c
--- a/usr.sbin/traceroute/as.c  Tue Jan 04 10:23:40 2011 +0000
+++ b/usr.sbin/traceroute/as.c  Tue Jan 04 10:26:56 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: as.c,v 1.2 2008/04/28 20:24:17 martin Exp $    */
+/*     $NetBSD: as.c,v 1.3 2011/01/04 10:26:56 wiz Exp $       */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -119,10 +119,12 @@
                asn->as_f = f;
 
 #ifdef AS_DEBUG_FILE
-       asn->as_debug = fopen(AS_DEBUG_FILE, "w");
-       if (asn->as_debug) {
-               (void)fprintf(asn->as_debug, ">> !!\n");
-               (void)fflush(asn->as_debug);
+       if (asn) {
+               asn->as_debug = fopen(AS_DEBUG_FILE, "w");
+               if (asn->as_debug) {
+                       (void)fprintf(asn->as_debug, ">> !!\n");
+                       (void)fflush(asn->as_debug);
+               }
        }
 #endif /* AS_DEBUG_FILE */
 



Home | Main Index | Thread Index | Old Index