mirror of https://github.com/vitalif/openscad
cmd buffer overflow test simplified
parent
74c5094cb0
commit
8e7902867d
|
@ -64,16 +64,14 @@ int main( int argc, char * argv[] )
|
||||||
if (quote) cmd[n++] = '"';
|
if (quote) cmd[n++] = '"';
|
||||||
while (*s) { // copy & check
|
while (*s) { // copy & check
|
||||||
if ('"' == *s) cmd[n++] = *s; // duplicate it
|
if ('"' == *s) cmd[n++] = *s; // duplicate it
|
||||||
if (n >= MAXCMDLEN-sizeof(redirect_str)) goto term;
|
|
||||||
cmd[n++] = *s++;
|
cmd[n++] = *s++;
|
||||||
}
|
|
||||||
if (quote) cmd[n++] = '"';
|
|
||||||
}
|
|
||||||
term:
|
|
||||||
if (n >= MAXCMDLEN-sizeof(redirect_str)) {
|
if (n >= MAXCMDLEN-sizeof(redirect_str)) {
|
||||||
fprintf(stderr, "Command line length exceeds limit of %d\n", MAXCMDLEN);
|
fprintf(stderr, "Command line length exceeds limit of %d\n", MAXCMDLEN);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (quote) cmd[n++] = '"';
|
||||||
|
}
|
||||||
memcpy(&cmd[n], redirect_str, sizeof(redirect_str)); // including \0
|
memcpy(&cmd[n], redirect_str, sizeof(redirect_str)); // including \0
|
||||||
|
|
||||||
cmd_stdout = _popen( cmd, "rt" );
|
cmd_stdout = _popen( cmd, "rt" );
|
||||||
|
|
Loading…
Reference in New Issue