user/4998: netcat has incorrect flag checks and unnecessary initializations

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

user/4998: netcat has incorrect flag checks and unnecessary initializations

Ray Lai-2
>Number:         4998
>Category:       user
>Synopsis:       netcat has incorrect flag checks and unnecessary initializations
>Confidential:   yes
>Severity:       non-critical
>Priority:       medium
>Responsible:    bugs
>State:          open
>Quarter:        
>Keywords:      
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 01 07:20:02 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Ray Lai
>Release:        3.9-beta
>Organization:
net
>Environment:
       
        System      : OpenBSD 3.9
        Architecture: OpenBSD.i386
        Machine     : i386
>Description:
Lines 486 and 489 check that only one flag is set and seems to want
to initialize sflag and pflag if they are uninitialized.  Since
both are global variables, both are set to NULL automatically and
this initialization block is unnecessary.

Line 490 sets sflag to NULL if !sflag, which is pointless.

>How-To-Repeat:

>Fix:
Index: netcat.c
===================================================================
RCS file: /home/ray/openbsd/src/usr.bin/nc/netcat.c,v
retrieving revision 1.85
diff -u -r1.85 netcat.c
--- netcat.c 20 Jan 2006 00:01:20 -0000 1.85
+++ netcat.c 31 Jan 2006 07:51:23 -0000
@@ -486,13 +486,6 @@
  if (sflag || pflag) {
  struct addrinfo ahints, *ares;
 
- if (!(sflag && pflag)) {
- if (!sflag)
- sflag = NULL;
- else
- pflag = NULL;
- }
-
  memset(&ahints, 0, sizeof(struct addrinfo));
  ahints.ai_family = res0->ai_family;
  ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM;


>Release-Note:
>Audit-Trail:
>Unformatted: