[MPlayer-dev-eng] [PATCH] fix "Unknown argument" with cmd containing spaces

Aurelien Jacobs aurel at gnuage.org
Wed Feb 9 19:24:57 CET 2005


Hi,

I've just found a bug in mp_input_parse_cmd.
First an example (silly but simple enough to show the bug).
Trying to parse :
  run 'ls -l'
will display :
  Unknown argument 1
But the command is still executed correctly.

When a string arg begin with a ' or a ", the parser read it up
to the closing ' or ". But after reading an argument, the parser
try to find the next one by searching for a space in the string,
begining at the START of last argument.
So with my example, the parser will first extract the command (run)
and then will parse the following string :
   'ls -l'
It will then set arg[0] = "ls -l" and will search for the next space
character. So it will then try to parse this string :
   -l'
Which is what causes the "Unknown argument 1".

This patch simply set ptr to the end of the parsed argument when
when encounter a quoted string, so we can't step on a space inside
this string.

Aurel
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cmd-space.diff
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20050209/895d7f5f/attachment.txt>


More information about the MPlayer-dev-eng mailing list