bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Fix variable-sized c strings


From: Justus Winter
Subject: [PATCH] Fix variable-sized c strings
Date: Fri, 21 Feb 2014 23:12:03 +0100

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.
---
 server.c | 5 +++++
 user.c   | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/server.c b/server.c
index 129cec3..a3368f6 100644
--- a/server.c
+++ b/server.c
@@ -912,6 +912,11 @@ WritePackArgValue(FILE *file, const argument_t *arg)
                arg->argMsgField,
                arg->argVarName,
                it->itNumber);
+           fprintf(file,
+               "\tif (OutP->%s < %d) OutP->%s += 1;\n",
+               arg->argCount->argMsgField,
+               it->itNumber,
+               arg->argCount->argMsgField);
        }
        else {
            argument_t *count = arg->argCount;
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 {
 
-- 
1.8.5.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]