From bb06f65290c2526d214302ba43bb6bc363cd4868 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 21 Feb 2014 21:44:15 +0100 Subject: Fix variable-sized c strings Previously, the terminating zero of variable-sized c strings was only included when copying the message if the length of the string was not a multiple of four. mig_strncpy returns the length of the string excluding the terminating zero. Fix this by properly accounting for the byte for the terminating zero in the array length. * server.c (WritePackArgValue): Account for the terminating zero in the array length. * user.c (WritePackArgValue): Likewise. --- user.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'user.c') diff --git a/user.c b/user.c index 37f53d2..f4a6cd5 100644 --- a/user.c +++ b/user.c @@ -411,6 +411,11 @@ WritePackArgValue(FILE *file, const argument_t *arg) arg->argMsgField, arg->argVarName, it->itNumber); + fprintf(file, + "\tif (InP->%s < %d) InP->%s += 1;\n", + arg->argCount->argMsgField, + it->itNumber, + arg->argCount->argMsgField); } else { -- cgit v1.2.3