From 25075c27222e3ce58d6c352d9e5ecf2e9705b153 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 30 Aug 2020 04:58:02 -0400 Subject: [PATCH] Fix round-tripping plPythonFileMod through HSPlasma. 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. --- core/PRP/Modifier/plPythonFileMod.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/PRP/Modifier/plPythonFileMod.cpp b/core/PRP/Modifier/plPythonFileMod.cpp index 2e7437056..de5f06584 100644 --- a/core/PRP/Modifier/plPythonFileMod.cpp +++ b/core/PRP/Modifier/plPythonFileMod.cpp @@ -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;