All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] Fix ckpt_write_err() check for empty string
@ 2009-10-14  0:53 Matt Helsley
       [not found] ` <1255481585-32625-1-git-send-email-matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Helsley @ 2009-10-14  0:53 UTC (permalink / raw)
  To: Oren Laadan; +Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

The test for empty error strings does not work because we always add 2
to len before testing if it's 0. Fix by checking before adding 2.

Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
 checkpoint/checkpoint.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/checkpoint/checkpoint.c b/checkpoint/checkpoint.c
index eaa9105..5a76d2b 100644
--- a/checkpoint/checkpoint.c
+++ b/checkpoint/checkpoint.c
@@ -258,11 +258,11 @@ int ckpt_write_err(struct ckpt_ctx *ctx, char *fmt0, char *fmt, ...)
 	}
 
 	str = ctx->err_string;
-	len = strlen(str + 1) + 2;	/* leading and trailing '\0' */
-
+	len = strlen(str + 1);
 	if (len == 0)	/* empty error string */
 		return 0;
 
+	len += 2; 	/* leading and trailing '\0' */
 	ret = ckpt_write_obj_type(ctx, NULL, 0, CKPT_HDR_ERROR);
 	if (!ret)
 		ret = ckpt_write_string(ctx, str, len);
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/4] Fix ckpt_write_err() check for empty string
       [not found] ` <1255481585-32625-1-git-send-email-matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
@ 2009-10-14 22:32   ` Oren Laadan
  0 siblings, 0 replies; 2+ messages in thread
From: Oren Laadan @ 2009-10-14 22:32 UTC (permalink / raw)
  To: Matt Helsley; +Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA


(This is the same one you posted some time ago ...)

Pulled, thanks.

Matt Helsley wrote:
> The test for empty error strings does not work because we always add 2
> to len before testing if it's 0. Fix by checking before adding 2.
> 
> Signed-off-by: Matt Helsley <matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> ---
>  checkpoint/checkpoint.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/checkpoint/checkpoint.c b/checkpoint/checkpoint.c
> index eaa9105..5a76d2b 100644
> --- a/checkpoint/checkpoint.c
> +++ b/checkpoint/checkpoint.c
> @@ -258,11 +258,11 @@ int ckpt_write_err(struct ckpt_ctx *ctx, char *fmt0, char *fmt, ...)
>  	}
>  
>  	str = ctx->err_string;
> -	len = strlen(str + 1) + 2;	/* leading and trailing '\0' */
> -
> +	len = strlen(str + 1);
>  	if (len == 0)	/* empty error string */
>  		return 0;
>  
> +	len += 2; 	/* leading and trailing '\0' */
>  	ret = ckpt_write_obj_type(ctx, NULL, 0, CKPT_HDR_ERROR);
>  	if (!ret)
>  		ret = ckpt_write_string(ctx, str, len);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-14 22:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-14  0:53 [PATCH 1/4] Fix ckpt_write_err() check for empty string Matt Helsley
     [not found] ` <1255481585-32625-1-git-send-email-matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-14 22:32   ` Oren Laadan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.