bug-hurd
[Top][All Lists]
Advanced

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

Re: [PATCH] Fix variable-sized c strings


From: Samuel Thibault
Subject: Re: [PATCH] Fix variable-sized c strings
Date: Sat, 22 Feb 2014 07:54:28 -0800
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

Justus Winter, le Fri 21 Feb 2014 23:12:03 +0100, a écrit :
> 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.

Do you know in which case this code is actually hit?  I have a hard time
reviewing the change without knowing what the generated code around
looks like :)

> * 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
> 

-- 
Samuel
<k> faut en profiter, aujourd'hui, les blagues bidon sont à 100 dollars
 -+- #sos-bourse -+-



reply via email to

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