Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84 SMI; site sun.uucp Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.bugs.usg Subject: "xargs" dereferences null pointers Message-ID: <2733@sun.uucp> Date: Fri, 30-Aug-85 20:16:13 EDT Article-I.D.: sun.2733 Posted: Fri Aug 30 20:16:13 1985 Date-Received: Sun, 1-Sep-85 06:02:22 EDT Distribution: net Organization: Sun Microsystems, Inc. Lines: 43 It scans the argument list for flag arguments under the assumption that the null pointer at the end of the argument list points to a string which doesn't begin with a "-". Sloppy, guys; a null pointer doesn't point to *anything*, especially on a Sun... *** /arch/s5r2/usr/src/cmd/xargs.c Wed Jun 15 19:15:26 1983 --- ./xargs.c Thu Aug 29 15:01:19 1985 *************** *** 55,61 /* look for flag arguments */ ! while ( (*argv)[0] == '-' ) { flagval = *argv+1; switch ( *flagval++ ) { case 'x': DASHX = LEGAL = TRUE; --- 55,61 ----- /* look for flag arguments */ ! while ( argc != 0 && (*argv)[0] == '-' ) { flagval = *argv+1; switch ( *flagval++ ) { case 'x': DASHX = LEGAL = TRUE; *************** *** 104,110 break; } argv++; ! if ( --argc < 1 ) break; } if( ! OK ) ERR = TRUE; --- 104,110 ----- break; } argv++; ! argc--; } if( ! OK ) ERR = TRUE;