commit 6c4b92f9e9a8ac9f9df3ca1cc5ddb50b4faaaf3f Author: Flavio Cruz Date: Sun Feb 9 22:38:26 2025 -0500 Server routines: ensure that strings in the request are null terminated before calling the server routine Message-ID: diff --git a/server.c b/server.c index 8da231c..9d25573 100644 --- a/server.c +++ b/server.c @@ -766,6 +766,14 @@ WriteExtractArg(FILE *file, const argument_t *arg) WriteInitializeCount(file, arg); } + /* Ensure strings are null-terminated */ + const ipc_type_t *it = arg->argType; + if (akCheck(arg->argKind, akbSend) && it->itString && !it->itVarArray) { + const size_t total_bytes = (it->itSize * it->itNumber)/8; + fprintf(file, "\t/* Ensure %s is null-terminated */\n", arg->argVarName); + fprintf(file, "\t%s[%d] = \'\\0\';\n", InArgMsgField(arg), total_bytes - 1); + } + if (akCheckAll(arg->argKind, akbReturnSnd|akbPointer)) WriteInitializePtr(file, arg); if (akCheckAll(arg->argKind, akbSendRcv|akbPointer)) {