rpms/cscope/F-12 cscope-15.6-invalid-opt.patch, NONE, 1.1 cscope.spec, 1.39, 1.40

Neil Horman nhorman at fedoraproject.org
Wed Dec 9 20:38:08 UTC 2009


Author: nhorman

Update of /cvs/extras/rpms/cscope/F-12
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv15450

Modified Files:
	cscope.spec 
Added Files:
	cscope-15.6-invalid-opt.patch 
Log Message:
Resolves: bz545816

cscope-15.6-invalid-opt.patch:
 main.c |  137 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 136 insertions(+), 1 deletion(-)

--- NEW FILE cscope-15.6-invalid-opt.patch ---
diff -up cscope-15.6/src/main.c.orig cscope-15.6/src/main.c
--- cscope-15.6/src/main.c.orig	2009-12-09 15:31:10.000000000 -0500
+++ cscope-15.6/src/main.c	2009-12-09 15:31:19.000000000 -0500
@@ -53,6 +53,9 @@
 #include <sys/types.h>	/* needed by stat.h */
 #include <sys/stat.h>	/* stat */
 #include <signal.h>
+#ifdef _GNU_SOURCE
+#include <getopt.h>
+#endif
 
 /* defaults for unset environment variables */
 #define	EDITOR	"vi"
@@ -132,6 +135,124 @@ sigwinch_handler(int sig, siginfo_t *inf
 }
 #endif
 
+#ifdef _GNU_SOURCE
+struct option lopts[] = {
+	{"help", 0, NULL, 'h'},
+	{"version", 0, NULL, 'V'},
+	{0, 0, 0, 0}
+};
+
+char ** parse_options(int *argc, char **argv)
+{
+	int opt;
+	int optind;
+	char path[PATHLEN + 1];     /* file path */
+	char *s;
+	int args_handled = 1;
+	int argcc = *argc;
+	
+
+	while ((opt = getopt_long(argcc, argv,
+	       "hVbcCdeF:f:I:i:kLl0:1:2:3:4:5:6:7:8:9:P:p:qRs:TUuv",
+	       lopts, &optind)) != -1) {
+		args_handled++;
+		switch(opt) {
+
+		case '?':
+			usage();
+			myexit(1);
+			break;
+		case 'b':	/* only build the cross-reference */
+			buildonly = YES;
+			linemode  = YES;
+			break;
+		case 'c':	/* ASCII characters only in crossref */
+			compress = NO;
+			break;
+		case 'C':	/* turn on caseless mode for symbol searches */
+			caseless = YES;
+			egrepcaseless(caseless); /* simulate egrep -i flag */
+			break;
+		case 'd':	/* consider crossref up-to-date */
+			isuptodate = YES;
+			break;
+		case 'e':	/* suppress ^E prompt between files */
+			editallprompt = NO;
+			break;
+		case 'k':	/* ignore DFLT_INCDIR */
+			kernelmode = YES;
+			break;
+		case 'L':
+			onesearch = YES;
+			/* FALLTHROUGH */
+		case 'l':
+			linemode = YES;
+			break;
+		case 'v':
+			verbosemode = YES;
+			break;
+		case 'q':	/* quick search */
+			invertedindex = YES;
+			break;
+		case 'T':	/* truncate symbols to 8 characters */
+			trun_syms = YES;
+			break;
+		case 'u':	/* unconditionally build the cross-reference */
+			unconditional = YES;
+			break;
+		case 'U':	/* assume some files have changed */
+			fileschanged = YES;
+			break;
+		case 'R':
+			recurse_dir = YES;
+			break;
+		case 'f':	/* alternate cross-reference file */
+			reffile = optarg;
+			if (strlen(reffile) > sizeof(path) - 3) {
+				postfatal("\
+					cscope: reffile too long, cannot \
+					be > %d characters\n", sizeof(path) - 3);
+				/* NOTREACHED */
+			}
+			strcpy(path, reffile);
+
+			s = path + strlen(path);
+			strcpy(s, ".in");
+			invname = my_strdup(path);
+			strcpy(s, ".po");
+			invpost = my_strdup(path);
+			break;
+
+		case 'F':	/* symbol reference lines file */
+			reflines = optarg;
+			break;
+		case 'i':	/* file containing file names */
+			namefile = optarg;
+			break;
+		case 'I':	/* #include file directory */
+			includedir(optarg);
+			break;
+		case 'p':	/* file path components to display */
+			dispcomponents = atoi(optarg);
+			break;
+		case 'P':	/* prepend path to file names */
+			prependpath = optarg;
+			break;
+		case 's':	/* additional source file directory */
+			sourcedir(optarg);
+			break;
+		}
+	}
+	/*
+ 	 * This adjusts argv so that we only see the remaining 
+ 	 * args.  Its ugly, but we need to do it so that the rest
+ 	 * of the main routine doesn't get all confused
+ 	 */
+	*argc = *argc - args_handled;
+	return &argv[*argc];
+}
+#endif
+
 int
 main(int argc, char **argv)
 {
@@ -155,6 +276,9 @@ main(int argc, char **argv)
     argv0 = argv[0];
 
     /* set the options */
+#ifdef _GNU_SOURCE
+	argv = parse_options(&argc, argv);
+#else
     while (--argc > 0 && (*++argv)[0] == '-') {
 	/* HBB 20030814: add GNU-style --help and --version options */
 	if (strequal(argv[0], "--help")
@@ -174,7 +298,17 @@ main(int argc, char **argv)
 	}
 
 	for (s = argv[0] + 1; *s != '\0'; s++) {
-			
+
+	    if ((*s != 'f') && (*s != 'F') &&
+		(*s != 'i') && (*s != 'I') &&
+		(*s != 'p') && (*s != 'P') &&
+		(*s != 's') && (*s != 'S')) {
+			if (*(s+1) != '\0') {
+				usage();
+				myexit(1);
+			}
+		}
+
 	    /* look for an input field number */
 	    if (isdigit((unsigned char) *s)) {
 		field = *s - '0';
@@ -324,6 +458,7 @@ cscope: reffile too long, cannot be > %d
     } /* while(argv) */
 
  lastarg:
+#endif
     /* read the environment */
     editor = mygetenv("EDITOR", EDITOR);
     editor = mygetenv("VIEWER", editor); /* use viewer if set */


Index: cscope.spec
===================================================================
RCS file: /cvs/extras/rpms/cscope/F-12/cscope.spec,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -p -r1.39 -r1.40
--- cscope.spec	24 Jul 2009 19:43:42 -0000	1.39
+++ cscope.spec	9 Dec 2009 20:38:08 -0000	1.40
@@ -1,7 +1,7 @@
 Summary: C source code tree search and browse tool 
 Name: cscope
 Version: 15.6
-Release: 5%{?dist}
+Release: 6%{?dist}
 Source0: http://unc.dl.sourceforge.net/sourceforge/cscope/cscope-15.6.tar.gz 
 URL: http://cscope.sourceforge.net
 License: BSD 
@@ -19,6 +19,7 @@ Patch2:cscope-15.6-xcscope-man.patch
 Patch3:cscope-15.6-sigwinch-linemode.patch
 Patch4:cscope-15.6-qrebuild.patch
 Patch5:cscope-15.6-incdir-overflow.patch
+Patch6:cscope-15.6-invalid-opt.patch
 
 %description
 cscope is a mature, ncurses based, C source code tree browsing tool.  It 
@@ -35,8 +36,10 @@ matches for use in file editing.
 %patch3 -p1
 %patch4 -p1
 %patch5 -p1
+%patch6 -p1
 
 %build
+export CFLAGS="-g -O2 -D_GNU_SOURCE"
 %configure
 make
 
@@ -83,6 +86,9 @@ rm -f %{xemacs_lisp_path}/xcscope.el
 rm -f %{emacs_lisp_path}/xcscope.el
 
 %changelog
+* Wed Dec 09 2009 Neil Horman <nhorman at redhat.com>
+- Fixed broken parsing of invalid options (bz 545816)
+
 * Fri Jul 24 2009 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 15.6-5
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
 




More information about the scm-commits mailing list