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

Re: [PATCH makedepend] Don't crash if an option's argument is missing



On 07/ 1/13 10:04 AM, Julien Cristau wrote:
Avoid dereferencing argv[argc].

See http://www.forallsecure.com/bug-reports/011f1a55f79a5501b36008d6ee0d40e8b6644569/

Reported-by: Alexandre Rebert <alexandre@cmu.edu>
Signed-off-by: Julien Cristau <jcristau@debian.org>
---
  main.c |   16 ++++++++++++++++
  1 file changed, 16 insertions(+)

diff --git a/main.c b/main.c
index e42b0cf..6ccb09b 100644
--- a/main.c
+++ b/main.c
@@ -242,6 +242,8 @@ main(int argc, char *argv[])
  			break;
  		case 'D':
  			if (argv[0][2] == '\0') {
+                                if (argc < 2)
+					fatalerr("Missing argument for -D\n");

Code is fine, but it appears that you've used spaces on the if line &
tabs on the fatalerr() line in each place, making the indentation look
funny in a few spots - would be nice to do a quick global-replace to
clean that up.

Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>

--
	-Alan Coopersmith-              alan.coopersmith@oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


Reply to: