• Code change suggestions

    From Wilfred van Velzen@2:280/464 to Developers on Thu Feb 13 16:29:02 2014
    Hi Developers,

    I want to suggest the following changes to the makenl code:

    diff --git a/src/lsttool.c b/src/lsttool.c
    index 467905f..3142a8b 100644
    -+- a/src/lsttool.c
    +++ b/src/lsttool.c
    @@ -41,7 +41,7 @@ int makearc(char *filename, int move)
    char name[MYMAXFILE];
    char fullpath[MYMAXPATH];
    char cmdlinebuf[MYMAXPATH];
    - char arccommand[ARCCMDMAX];
    + char *arccommand;

    if (os_filesize(filename) <= ARCThreshold || ARCThreshold == -1)
    {
    @@ -54,12 +54,12 @@ int makearc(char *filename, int move)
    if (toupper((int) ext[0]) == 'D') /* Autogenerated diff - can always be moved */
    {
    ext[1] = 'd';
    - strlcpy(arccommand, ArcMoveCmd, sizeof arccommand); /* move instead of
    add */
    + arccommand = ArcMoveCmd; /* move instead of add */
    ext[0] = ArcMoveExt[0];
    }
    else
    {
    - strlcpy(arccommand, (move < 1) ? ArcCopyCmd : ArcMoveCmd, sizeof arccommand);
    + arccommand = (move < 1) ? ArcCopyCmd : ArcMoveCmd;
    ext[0] = (move < 1) ? ArcCopyExt[0] : ArcMoveExt[0];
    }
    myfnmerge(fullpath, NULL, OutDir, name, ext);
    diff --git a/src/makenl.h b/src/makenl.h
    index e78b804..888e65e 100644
    -+- a/src/makenl.h
    +++ b/src/makenl.h
    @@ -18,7 +18,7 @@ extern int JustTest;
    extern int debug_mode;

    #define linelength 512
    -#define ARCCMDMAX 20
    +#define ARCCMDMAX 256
    #define ARCEXTMAX 4
    #define ARCUNPMAX 10

    I was hit by the (undocumented) arcopy and arcmove command line limit of 20 chars when I upgraded from 3.2.9b to 3.4.2.

    The configuration lines I use are:

    arccopy l /usr/local/bin/lha cqi
    arcmove l /usr/local/bin/lha cqi

    Which needs a command line buffer of at least 23 chars.

    Because in the 3.4.2 version (or a version inbetween) fixes a bug where the command line length wasn't checked when it copied the string from the configuration file, it used to work with the 3.2.9b version. But no longer in the 3.4.2, so I got an error when the arccopy command was executed by makenl in
    my configuration, because the command line was cut short...

    256 is still arbitrary, but should be enough for most systems. ;)


    Bye, Wilfred.

    --- FMail-W32-1.67.0.46-B20140112
    * Origin: Amiga Offline BBS Lisse (2:280/464)
  • From Andrew Leary@1:320/119 to Wilfred van Velzen on Fri Feb 14 07:42:00 2014
    Hello Wilfred!

    Thursday February 13 2014 16:29, Wilfred van Velzen wrote to Developers:

    Hi Developers,
    I want to suggest the following changes to the makenl code:

    I will most likely incorporate these for 3.4.3. Thanks for the suggestions.

    I was hit by the (undocumented) arcopy and arcmove command line limit
    of 20 chars when I upgraded from 3.2.9b to 3.4.2.

    The configuration lines I use are:

    arccopy l /usr/local/bin/lha cqi
    arcmove l /usr/local/bin/lha cqi

    Which needs a command line buffer of at least 23 chars.

    Because in the 3.4.2 version (or a version inbetween) fixes a bug
    where the command line length wasn't checked when it copied the string from the configuration file, it used to work with the 3.2.9b version.
    But no longer in the 3.4.2, so I got an error when the arccopy command was executed by makenl in my configuration, because the command line
    was cut short...

    Yes, andrew clarke has done a bunch of work on preventing overflows, including at least one that I created a few versions ago. OOPS!

    256 is still arbitrary, but should be enough for most systems. ;)

    I would hope so!

    Regards,

    Andrew

    ---
    * Origin: Bits & Bytes BBS * V.Everything! * 860/535-4284 (1:320/119)
  • From Wilfred van Velzen@2:280/464 to Andrew Leary on Fri Feb 14 14:39:04 2014
    Hi Andrew,

    On 2014-02-14 07:42:00, you wrote to me:

    I want to suggest the following changes to the makenl code:

    I will most likely incorporate these for 3.4.3. Thanks for the suggestions.

    Your welcome...

    Because in the 3.4.2 version (or a version inbetween) fixes a bug
    where the command line length wasn't checked when it copied the
    string from the configuration file, it used to work with the 3.2.9b
    version. But no longer in the 3.4.2, so I got an error when the
    arccopy command was executed by makenl in my configuration, because
    the command line was cut short...

    Yes, andrew clarke has done a bunch of work on preventing overflows, including at least one that I created a few versions ago. OOPS!

    Yes, I noticed these when comparing sources for 3.2.9 and 3.4.2. Great work! Because it could prevent some possible buffer overflows!

    256 is still arbitrary, but should be enough for most systems. ;)

    I would hope so!

    Well, you never know. ;)
    MAX_PATH on windows for instance, is 260 bytes. And that's just for the command, not for command line options. And just today I noticed a command line to start java on a linux server that was over 1300 bytes long. But I don't think we will see that in the makenl config to start an archiver. Although if someone wants to write the options in --long-format for readability...

    Bye, Wilfred.

    --- FMail-W32-1.67.0.46-B20140112
    * Origin: Amiga Offline BBS Lisse (2:280/464)