Menu

#224 Setting multiple relative paths for bundled JREs is not working

3.x
closed-fixed
None
5
2022-11-13
2022-11-02
No

Setting multiple relative paths for bundled JREs is not working.
This is trivial to reproduce and fix, as it seems to be a string manipulation issue in head.c.

I believe the issue is caused by the following line:

strncpy(launcher.cmd, exePath, pathLen);

It doesn't add a null terminator to launcher.cmd string, right?
Using pathLen + 1 or explicit adding a null terminator launcher.cmd[pathLen] = 0; should fix it.

Relevant part of launch4j.log:

Bundled JRE(s): 1;2;3
Check launcher: D:\A2\1\bin\javaw.exe (not found)
Check launcher: D:\A2\1\2\bin\javaw.exe (not found)
Check launcher: D:\A2\1\2\3\bin\javaw.exe (not found)

Related

Bugs: #224

Discussion

  • Grzegorz Kowal

    Grzegorz Kowal - 2022-11-02

    Hi, thanks for pointing this out - I will have a look during testing of
    latest changes in the search.

    Best regards,
    Grzegorz

    On Wed, Nov 2, 2022, 13:36 Wladimir Leite tc-wleite@users.sourceforge.net
    wrote:


    Status: open
    Group: 3.x
    Created: Wed Nov 02, 2022 12:36 PM UTC by Wladimir Leite
    Last Updated: Wed Nov 02, 2022 12:36 PM UTC
    Owner: nobody

    Setting multiple relative paths for bundled JREs is not working.
    This is trivial to reproduce and fix, as it seems to be a string
    manipulation issue in head.c.

    I believe the issue is caused by the following line:

    strncpy(launcher.cmd, exePath, pathLen);

    It doesn't add a null terminator to launcher.cmd string, right?
    Using pathLen + 1 or explicit adding a null terminator launcher.cmd[pathLen]
    = 0; should fix it.

    Relevant part of launch4j.log:

    Bundled JRE(s): 1;2;3
    Check launcher: D:\A2\1\bin\javaw.exe (not found)
    Check launcher: D:\A2\1\2\bin\javaw.exe (not found)
    Check launcher: D:\A2\1\2\3\bin\javaw.exe (not found)


    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/launch4j/bugs/224/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

     
    👍
    1

    Related

    Bugs: #224

  • Grzegorz Kowal

    Grzegorz Kowal - 2022-11-08

    You're right, the problem was that this particular array was reused and then the missing terminator caused the problem.

    Best regards,
    Grzegorz

     
    👍
    1
  • Grzegorz Kowal

    Grzegorz Kowal - 2022-11-08
    • status: open --> closed
    • assigned_to: Grzegorz Kowal
     
  • Grzegorz Kowal

    Grzegorz Kowal - 2022-11-08

    You're right, the problem was that this particular array was reused and then the missing terminator caused the problem.

    Committing fix.

    Best regards,
    Grzegorz

     
  • Wladimir Leite

    Wladimir Leite - 2022-11-08

    Thank you Grzegorz for the quick fix and the great tool!

     
  • Grzegorz Kowal

    Grzegorz Kowal - 2022-11-13
    • status: closed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB