changeset 14294:90bcd37dba7f

fix string argument parsing (e.g. one char strings were not accepted)
author reimar
date Sat, 01 Jan 2005 19:03:22 +0000
parents eadb2d8d5232
children 988be6af1d48
files subopt-helper.c
diffstat 1 files changed, 5 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/subopt-helper.c	Sat Jan 01 18:59:33 2005 +0000
+++ b/subopt-helper.c	Sat Jan 01 19:03:22 2005 +0000
@@ -234,23 +234,14 @@
   char const * match = strchr( str, ':' );
 
   if ( !match )
-  {
-    if ( str[1] != '\0' )
-    {
-      int len = strlen( &str[1] );
-      match = str + 1 + len;
-    }
-    else
-    {
-      return NULL;
-    }
-  }
+    match = &str[strlen(str)];
+
+  // empty string or too long
+  if ((match == str) || (match - str > 255))
+    return NULL;
 
   valp->len = match - str;
   valp->str = str;
 
-  /* if the length is zero, indicate error */
-  if ( valp->len == 0 ) { return NULL; }
-
   return match;
 }