Git Product home page Git Product logo

Comments (6)

schinagl avatar schinagl commented on July 2, 2024

Are you using Winfile 10.2.0.0?
How did you determine that the args were garbled? Printing the args from MyProgram.exe?

If I debug Winfile the args 'leave' winfile via ShellExecute() in shape.
Are you sure the problem is not in MyProgram.exe when printing the args?
As far as I remember command lines are limited to 255 characters, but I could be wrong.

from winfile.

malxau avatar malxau commented on July 2, 2024

@ScottHollows I'd second schinagl's question - which release are you using? Also, which version of Windows?

I think the limitation is in RunDlgProc. Prior to #340 , this was limited to 260 chars (total.) In the latest release this should be over 1000.

Unfortunately that doesn't explain:

  • How the text is entered, because the control's width is limited to the buffer width via EM_LIMITTEXT
  • Garbled characters, which smells like a buffer overflow. Here the code is using lstrcpy into stack based buffers, but it "knows" that if all the text fit into the original buffer, substrings have to fit into component buffers. Also, GetDlgItemText is documented to NULL terminate on truncate.

Originally the code used a different constant for the parameter buffer length compared to the total buffer length, which seems unsafe, but as far as I can tell in this repo they always had the same value. If there was a build where RUN_LENGTH < MAXPATHLEN, this could happen.

from winfile.

schinagl avatar schinagl commented on July 2, 2024

@malxau : I hooked up with the debugger, then exactly entered the string specified by @ScottHollows, and was able see that it was fed into ShellExecute() exactly the right way.

So @ScottHollows please check MyProgramm.exe if it handles args properly

from winfile.

ScottHollows avatar ScottHollows commented on July 2, 2024

I wrote a test program that shows the parameters passed in to it and the length of the parameters

It runs ok from a DOS command line with 5000 characters
It also runs ok when called from a DOS batch program with 5000 characters

When I run it from File Manager > File Run it gets truncated around 1000 characters, with a bit of wiggle room that is probably the length of the program name

I have identified at least one issue where the File Run > Command Line field is limited to 1000 characters so there is no way to test parameters longer than that That 1000 limit is longer than the original 255 that I reported in my original post so must have done that test incorrectly - sorry about that. At a guess, I probably ran an older version of File Manager or I was running it in an virtual machine with an old version of Windows
When I run that same test now in Windows 10 (22H2) it correctly shows all 255 char

So, my original post was incorrect and the limit is around 1000 rather than the 255 that I reported

Since this is under review, can the limit for that Command Line field be increased to maybe 5000 characters ?

from winfile.

schinagl avatar schinagl commented on July 2, 2024

With #340 the length of path and all internal strings was increased to 1024.
#340 is part of 10.2.0.0

Thus the arguments of a command passed to File/Run can be 1024 characters.

I suggest to use .bat files for arguments longer than 1024 characters, because handling of so many characters in this tiny File/Run box is error prone.

from winfile.

ScottHollows avatar ScottHollows commented on July 2, 2024

Thanks for looking into this.

I am closing this issue now

from winfile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.