summaryrefslogtreecommitdiffstats
path: root/subopt-helper.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-01-01 19:03:22 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-01-01 19:03:22 +0000
commit0eb381415da119cb3bcac50116ddc1b4be6bd13d (patch)
tree167f225226c4f6292f4b43a7cad0fa9240240376 /subopt-helper.c
parentbe362405825b2fce55caad56fdbe823ed59c7927 (diff)
downloadmpv-0eb381415da119cb3bcac50116ddc1b4be6bd13d.tar.bz2
mpv-0eb381415da119cb3bcac50116ddc1b4be6bd13d.tar.xz
fix string argument parsing (e.g. one char strings were not accepted)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14295 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'subopt-helper.c')
-rw-r--r--subopt-helper.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/subopt-helper.c b/subopt-helper.c
index 7ae5512f3d..df2ceda639 100644
--- a/subopt-helper.c
+++ b/subopt-helper.c
@@ -234,23 +234,14 @@ static char const * parse_str( char const * const str, strarg_t * const valp )
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;
}