mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-03 10:54:42 +00:00
Fixes a buffer overrun where the allocated buffer wasn't large enough to accommodate the closing quote escape rules in some instances.
llvm-svn: 180836
This commit is contained in:
parent
5002c3f17d
commit
d8a98591d4
@ -155,7 +155,8 @@ static char *EscapePrecedingEscapes(char *Dst, const char *Start,
|
||||
/// CreateProcess and returns length of quoted arg with escaped quotes
|
||||
static unsigned int ArgLenWithQuotes(const char *Str) {
|
||||
const char *Start = Str;
|
||||
unsigned int len = ArgNeedsQuotes(Str) ? 2 : 0;
|
||||
bool Quoted = ArgNeedsQuotes(Str);
|
||||
unsigned int len = Quoted ? 2 : 0;
|
||||
|
||||
while (*Str != '\0') {
|
||||
if (*Str == '\"') {
|
||||
@ -171,6 +172,12 @@ static unsigned int ArgLenWithQuotes(const char *Str) {
|
||||
++Str;
|
||||
}
|
||||
|
||||
if (Quoted) {
|
||||
// Make sure the closing quote doesn't get escaped by a trailing backslash.
|
||||
unsigned PrecedingEscapes = CountPrecedingBackslashes(Start, Str);
|
||||
len += PrecedingEscapes + 1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user