Skip to content

Commit

Permalink
Fix round-tripping plPythonFileMod through HSPlasma.
Browse files Browse the repository at this point in the history
This fixes an issue in which PythonFileMods with string parameters would
be shattered by round-tripping through HSPlasma. The spurious null
terminator was being accumulated into the parameter, causing two nulls
to be serialized. This caused a null byte to be passed to CWE's Python,
resulting in a difficult to debug scenario where we had a seemingly
valid string object in Python but the validation in `PyArg_ParseTuple`
failed.
  • Loading branch information
Hoikas committed Aug 30, 2020
1 parent 80e2990 commit 25075c2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/PRP/Modifier/plPythonFileMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ void plPythonParameter::read(hsStream* S, plResManager* mgr)
case kSubtitle:
size = S->readInt();
if (size == 0) {
fStrValue = "";
fStrValue = ST::null;
return;
}
fStrValue = S->readStr(size);
fStrValue = S->readStr(size - 1);
S->readByte();
return;
case kNone:
return;
Expand Down

0 comments on commit 25075c2

Please sign in to comment.