#1462 "Zip unzip" does not properly parse invalid flags

closed
5
2012-06-13
2012-06-06
asomers
No

When doing an unzip command, if the last word on the command line is an invalid flag, STAF will not reject the command. Instead, it will combine the last word with the directory name, and unzip the files to a directory of the form "dirname lastword" (note the space).

For example, if PWD is "/tmp/ziptest", then
"staf local zip unzip zipfile /tmp/ziptest/test.zip todirectory $PWD restorepermission" will extract files to "/tmp/ziptest", but
"staf local zip unzip zipfile /tmp/ziptest/test.zip todirectory $PWD restorepermissions" will extract files to "/tmp/ziptest restorepermissions"

I encountered this bug using STAF 3.4.8 (with the patch for bug 3530590) on FreeBSD 9.0 amd64.

Discussion

  • Sharon Lucas

    Sharon Lucas - 2012-06-06

    This is actually a "feature" of the STAF command parser (so it is not specific to the ZIP service). It's purpose is to try to help when you don't specify double quotes (or use the colonLengthColon format) to distinguish when an option value begins or ends. Usually it is helpful, but in some cases (like this) not so much.

    For example, if PWD is the name of a directory that contains one or more blanks (e.g. /tmp/zip test). then

    STAF local ZIP UNZIP ZIPFILE /tmp/zip test/test.zip TODIRECTORY $PWD RESTOREPERMISSION

    works but only because the STAF command parser tried to help determine that the end of the option value for ZIPFILE and TODIRECTORY did not really end when a space was encountered (e.g. at "/tmp/zip" instead of at "/tmp/zip test") but instead ended when the next value option name (e.g. RESTOREPERMISSION) was encountered. If the command parser didn't try to "help", then this command would have failed with RC 7 (Invalid Request String).

    Similarly, a QUEUE service command like:

    STAF lcoal QUEUE QUEUE MESSAGE This is a test

    would fail if the STAF command parser did try to help by guessing that the message is "This is a test" instead of "This".

    Note that if you had specified the invalid RESTOREPERMISSIONS option before the ZIPFILE option, then the STAF command parser would have returned RC 7 (Invalid Request String).

    This "feature" of the STAF command parser has been there since the beginning so if we changed its behavior now, that could break existing code that relies on it and we don't want to do that (though I agree that it can be annoying when an invalid option is specified).

     
  • asomers

    asomers - 2012-06-06

    Weird. Thanks for explaining.

     
  • Sharon Lucas

    Sharon Lucas - 2012-06-13
    • assigned_to: nobody --> slucas
    • status: open --> closed
     

Log in to post a comment.