Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 48188 - mmsclient seg. faults when invalid urls are entered or when --version/--help are typed
Summary: mmsclient seg. faults when invalid urls are entered or when --version/--help ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Daniel Black (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-17 21:05 UTC by siefkenj
Modified: 2004-04-25 23:52 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
A patch file to fix mmsclient bugs (mms_client-0.0.4.patch,3.70 KB, patch)
2004-04-17 21:07 UTC, siefkenj
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description siefkenj 2004-04-17 21:05:32 UTC
mmsclient will seg. fault if any arguments other than a URL are given i.e. --help --version.  A url without a '/' will cause a segfault.  i.e. mms://google.com

Reproducible: Always
Steps to Reproduce:
1. mmsclient --version

Actual Results:  
Segmentation Fault

Expected Results:  
printout of the version or an error "Command not found"

I have written a patch:

-----------------------------------------------------------------

Only in mms_client-0.0.4: .Makefile
diff -u mms_client-0.0.3/AUTHORS mms_client-0.0.4/AUTHORS
--- mms_client-0.0.3/AUTHORS	2001-10-09 16:09:40.000000000 -0700
+++ mms_client-0.0.4/AUTHORS	2004-04-17 17:18:17.891514128 -0700
@@ -0,0 +1,5 @@
+Original Author:
+Major MMS <http://www.geocities.com/majormms/>
+
+Patch Contributers:
+Jason Siefken <http://oregonstate.edu/~siefkenj/>
diff -u mms_client-0.0.3/ChangeLog mms_client-0.0.4/ChangeLog
--- mms_client-0.0.3/ChangeLog	2001-10-09 16:09:47.000000000 -0700
+++ mms_client-0.0.4/ChangeLog	2004-04-17 17:05:27.014705216 -0700
@@ -0,0 +1,3 @@
+0.0.4
+	Fixed segmentation faults when invalid URL's are entered
+	Added --version and --help options
diff -u mms_client-0.0.3/Makefile.in mms_client-0.0.4/Makefile.in
--- mms_client-0.0.3/Makefile.in	2002-01-21 18:51:31.000000000 -0800
+++ mms_client-0.0.4/Makefile.in	2004-04-17 15:57:10.241509408 -0700
@@ -85,7 +85,7 @@
 mmsclient_DEPENDENCIES = 
 mmsclient_LDFLAGS = 
 CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
$(CFLAGS)
+COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
$(CFLAGS) "-DVERSION=\"$(VERSION)\""
 CCLD = $(CC)
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
 HEADERS =  $(noinst_HEADERS)
diff -u mms_client-0.0.3/README mms_client-0.0.4/README
--- mms_client-0.0.3/README	2001-10-09 16:09:36.000000000 -0700
+++ mms_client-0.0.4/README	2004-04-17 17:16:29.204037136 -0700
@@ -0,0 +1,2 @@
+mmsclient downloads MMS (Microsoft Media Server) streams, and 
+saves them to disk.
diff -u mms_client-0.0.3/client.c mms_client-0.0.4/client.c
--- mms_client-0.0.3/client.c	2001-12-28 19:40:48.000000000 -0800
+++ mms_client-0.0.4/client.c	2004-04-17 17:02:06.409201888 -0700
@@ -5,6 +5,9 @@
  * mms://193.159.244.12/n24_wmt_mid
  */
 
+#define HELPINFO "Usage: mmsclient mms://<url>\n -v --version\n\tPrint version
information\n -h --help\n\tPrint this page\nhttp://www.geocities.com/majormms/\n"
+
+
 #include <unistd.h>
 #include <stdio.h>
 #include <assert.h>
@@ -475,23 +478,44 @@
   char                *path, *url, *file, *cp;
 
   if (argc != 2) {
-    printf ("usage: %s url\n", argv[0]);
+    printf ("Usage: %s URL\n", argv[0]);
     exit(1);
   }
-
+  
+  /* check for non-url arguments (version or help ...) */
+  if (strncmp(argv[1], "mms://", 6) == 0 && argv[1][6] == 0){		/* Just typed
"mms://" with no URL */
+	printf("Error: No URL\n");
+	exit(1);
+  }
+  if (strncmp(argv[1], "mms://", 6) != 0){	/* haven't typed a url */
+	
+	if (strncmp(argv[1], "--version", 9) == 0 || strncmp(argv[1], "-v", 9) == 0){
+		printf("%s\n", VERSION);
+	}else if (strncmp(argv[1], "--help", 9) == 0 || strncmp(argv[1], "-h", 9) == 0){
+		printf("%s\n", HELPINFO);
+	}else{
+		printf("Error: unrecognized command %s\n", argv[1]); 
+	}
+	exit(1);
+  }
+  
   /* parse url */
   
   url = argv[1];
   strncpy (host, &url[6], 255);
   cp = strchr(host,'/');
-  *cp= 0;
+  if(cp == 0){			/* If they just typed a top level domain name */
+  	printf("Error: Incomplete URL '%s'\n", &url[6]);
+  	exit(1);
+  }
+  *cp= 0;			/* Make the '/' a null */
 
   printf ("host : >%s<\n", host);
 
   path = strchr(&url[6], '/') +1;
 
   printf ("path : >%s<\n", path);
-
+  
   file = strrchr (url, '/');
 
   printf ("file : >%s<\n", file);
diff -u mms_client-0.0.3/configure mms_client-0.0.4/configure
--- mms_client-0.0.3/configure	2002-01-21 18:50:51.000000000 -0800
+++ mms_client-0.0.4/configure	2004-04-17 16:47:01.126825728 -0700
@@ -694,7 +694,7 @@
 
 PACKAGE="mms_client"
 
-VERSION=0.0.3
+VERSION=0.0.4
 
 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
   { echo "configure: error: source directory already configured; run "make
distclean" there first" 1>&2; exit 1; }

--------------------------------------------------------------------------------
Comment 1 siefkenj 2004-04-17 21:07:20 UTC
Created attachment 29534 [details, diff]
A patch file to fix mmsclient bugs
Comment 2 Daniel Black (RETIRED) gentoo-dev 2004-04-24 19:06:33 UTC
Goodone - I hope you have submitted this upstream
Comment 3 Daniel Black (RETIRED) gentoo-dev 2004-04-25 23:52:47 UTC
Applied patch as is. I see the author wants to remain anonymous. Thankyou