summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Cruz <flaviocruz@gmail.com>2025-02-09 22:38:26 -0500
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2025-02-10 19:48:22 +0100
commit6c4b92f9e9a8ac9f9df3ca1cc5ddb50b4faaaf3f (patch)
treea93c1e04a548d6535188d73989ca2aac6400458a
parentd4ed2ed7fa36a2637f6f3b352ee2875abaf27092 (diff)
Server routines: ensure that strings in the request are null terminated before calling the server routine
Message-ID: <neoj66xitwcilmtlf3fek6tjal35tuetleyydiduuqvhkjisah@n2a2xwvoqrie>
-rw-r--r--server.c8
1 files changed, 8 insertions, 0 deletions
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)) {