-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Improve handling of very large arguments in the tracebld sample #83
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4266,7 +4266,7 @@ PWCHAR LoadCommandLine(PCWSTR pwz, PWCHAR pwzDst, PWCHAR pwzDstEnd) | |
// More arguments! | ||
WCHAR wzPath[MAX_PATH]; | ||
PWCHAR pwzPath = wzPath; | ||
PCWSTR pwzTmp = pwzArgBeg + 1; | ||
PCWSTR pwzTmp = pwzArgBeg; | ||
while (pwzTmp < pwzArgEnd && pwzPath < wzPath + ARRAYSIZE(wzPath)-2) { | ||
*pwzPath++ = *pwzTmp++; | ||
} | ||
|
@@ -4496,11 +4496,15 @@ int WINAPI Mine_EntryPoint(VOID) | |
|
||
FileNames::ParameterizeLine(pwzFin, pwzFin + wcNew); | ||
if (HasSpace(wzPath)) { | ||
Tblog("<t:Line>"%le" %le</t:Line>\n", wzPath, pwzFin); | ||
Tblog("<t:Line>"%le" ", wzPath); | ||
} | ||
else { | ||
Tblog("<t:Line>%le %le</t:Line>\n", wzPath, pwzFin); | ||
Tblog("<t:Line>%le ", wzPath); | ||
} | ||
for(PWCHAR pwzTmp = pwzFin; pwzTmp < pwzFin + wcNew; pwzTmp += 32764) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if pwzTmp is very large, it overflows the structure that passes this string to the host app. This solution sends it in parts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this does what you think it does. The problem is that the characters in the string are being escaped. Some input characters require 6 characters in the output. This means that the output may require more than 32764 characters. if it does, some characters in the input string may not be written. It is also not a good idea to embed a constant like 32764 here. This constant comes from tracebld.h, specifically the number of characters in szMessage in the definition of the struct |
||
Tblog("%le", pwzTmp); | ||
} | ||
Tblog("</t:Line>\n"); | ||
|
||
TestHandle("t:StdIn", GetStdHandle(STD_INPUT_HANDLE)); | ||
TestHandle("t:StdOut", GetStdHandle(STD_OUTPUT_HANDLE)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fix for an off-by-one error in response file parsing. Response file parsing doesn't work at all without this fix.