From root@mulet.e.kth.se  Wed Jan  6 09:46:22 1999
Received: from mulet.e.kth.se (mulet.e.kth.se [130.237.43.20])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA12266
          for <FreeBSD-gnats-submit@freebsd.org>; Wed, 6 Jan 1999 09:46:20 -0800 (PST)
          (envelope-from root@mulet.e.kth.se)
Received: (from root@localhost)
	by mulet.e.kth.se (8.9.1/8.9.1) id RAA02896;
	Wed, 6 Jan 1999 17:45:51 GMT
	(envelope-from root)
Message-Id: <199901061745.RAA02896@mulet.e.kth.se>
Date: Wed, 6 Jan 1999 17:45:51 GMT
From: assar@sics.se
To: FreeBSD-gnats-submit@freebsd.org
Subject: make doesn't diagnose non-numeric arguments to `-j' (and `-L')
X-Send-Pr-Version: 3.2

>Number:         9349
>Category:       bin
>Synopsis:       make doesn't diagnose non-numeric arguments to `-j' (and `-L')
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    hoek
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan  6 09:50:03 PST 1999
>Closed-Date:    Sat Jul 31 13:40:33 PDT 1999
>Last-Modified:  Sat Jul 31 13:41:18 PDT 1999
>Originator:     Assar Westerlund <assar@sics.se>
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
none
>Environment:

>Description:

make calls `atoi' instead of `strtol' to find errors with argument to
`-j', therefore not finding non-numeric arguments.

>How-To-Repeat:

make -j foobar

>Fix:

===================================================================
RCS file: RCS/main.c,v
retrieving revision 1.1
diff -uw -r1.1 main.c
--- main.c	1999/01/06 17:33:11	1.1
+++ main.c	1999/01/06 17:41:07
@@ -204,11 +204,19 @@
 			Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL);
 			break;
 #ifdef REMOTE
-		case 'L':
-			maxLocal = atoi(optarg);
+		case 'L': {
+			char *endptr;
+
+			maxLocal = strtol(optarg, &endptr, 0);
+			if (maxLocal == 0 && endptr == optarg) {
+				warnx("non-numeric argument to -L -- %s",
+				      optarg);
+				usage();
+			}
 			Var_Append(MAKEFLAGS, "-L", VAR_GLOBAL);
 			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
 			break;
+		}
 #endif
 		case 'P':
 			usePipes = FALSE;
@@ -282,15 +290,23 @@
 			ignoreErrors = TRUE;
 			Var_Append(MAKEFLAGS, "-i", VAR_GLOBAL);
 			break;
-		case 'j':
+		case 'j': {
+			char *endptr;
+
 			forceJobs = TRUE;
-			maxJobs = atoi(optarg);
+			maxJobs = strtol(optarg, &endptr, 0);
+			if (maxJobs == 0 && endptr == optarg) {
+				warnx("non-numeric argument to -j -- %s",
+				      optarg);
+				usage();
+			}
 #ifndef REMOTE
 			maxLocal = maxJobs;
 #endif
 			Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
 			Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
 			break;
+		}
 		case 'k':
 			keepgoing = TRUE;
 			Var_Append(MAKEFLAGS, "-k", VAR_GLOBAL);
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->hoek 
Responsible-Changed-By: hoek 
Responsible-Changed-When: Tue Jul 27 15:47:25 PDT 1999 
Responsible-Changed-Why:  
Currently testing patch... 
State-Changed-From-To: open->closed 
State-Changed-By: hoek 
State-Changed-When: Sat Jul 31 13:40:33 PDT 1999 
State-Changed-Why:  
Modified (see style(9)) patch applied.  Thanks! 
>Unformatted:
