All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.1] test-string-output-visitor: Fix unterminated string
@ 2014-07-09 14:14 Kevin Wolf
  2014-07-10  1:41 ` Eric Blake
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2014-07-09 14:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, hutao, qemu-trivial, mst

Don't forget to add a terminating '\0' or the test case will be randomly
failing. The broken code was added in commit b4900c0e.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/test-string-output-visitor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c
index e89e43c..f2c427f 100644
--- a/tests/test-string-output-visitor.c
+++ b/tests/test-string-output-visitor.c
@@ -201,11 +201,11 @@ static void test_visitor_out_enum(TestOutputVisitorData *data,
         visit_type_EnumOne(data->ov, &i, "unused", &err);
         g_assert(!err);
 
-        len = strlen(EnumOne_lookup[i]) + 2;
+        len = strlen(EnumOne_lookup[i]) + 3;
         str_human = g_malloc0(len);
         str_human[0] = '"';
         strncpy(str_human + 1, EnumOne_lookup[i], strlen(EnumOne_lookup[i]));
-        str_human[len - 1] = '"';
+        str_human[len - 2] = '"';
 
         str = string_output_get_string(data->sov);
         g_assert(str != NULL);
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PATCH for-2.1] test-string-output-visitor: Fix unterminated string
  2014-07-09 14:14 [Qemu-devel] [PATCH for-2.1] test-string-output-visitor: Fix unterminated string Kevin Wolf
@ 2014-07-10  1:41 ` Eric Blake
  2014-07-10  8:00   ` Kevin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Blake @ 2014-07-10  1:41 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel; +Cc: qemu-trivial, hutao, mst

[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]

On 07/09/2014 08:14 AM, Kevin Wolf wrote:
> Don't forget to add a terminating '\0' or the test case will be randomly
> failing. The broken code was added in commit b4900c0e.

Sorry, but I prefer this solution better:
https://lists.gnu.org/archive/html/qemu-devel/2014-07/msg01595.html

> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  tests/test-string-output-visitor.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/test-string-output-visitor.c b/tests/test-string-output-visitor.c
> index e89e43c..f2c427f 100644
> --- a/tests/test-string-output-visitor.c
> +++ b/tests/test-string-output-visitor.c
> @@ -201,11 +201,11 @@ static void test_visitor_out_enum(TestOutputVisitorData *data,
>          visit_type_EnumOne(data->ov, &i, "unused", &err);
>          g_assert(!err);
>  
> -        len = strlen(EnumOne_lookup[i]) + 2;
> +        len = strlen(EnumOne_lookup[i]) + 3;
>          str_human = g_malloc0(len);
>          str_human[0] = '"';
>          strncpy(str_human + 1, EnumOne_lookup[i], strlen(EnumOne_lookup[i]));
> -        str_human[len - 1] = '"';
> +        str_human[len - 2] = '"';

Manually doing this when g_strdup_printf can do it as a one-liner is
just lunacy.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH for-2.1] test-string-output-visitor: Fix unterminated string
  2014-07-10  1:41 ` Eric Blake
@ 2014-07-10  8:00   ` Kevin Wolf
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2014-07-10  8:00 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-trivial, hutao, qemu-devel, mst

[-- Attachment #1: Type: text/plain, Size: 424 bytes --]

Am 10.07.2014 um 03:41 hat Eric Blake geschrieben:
> On 07/09/2014 08:14 AM, Kevin Wolf wrote:
> > Don't forget to add a terminating '\0' or the test case will be randomly
> > failing. The broken code was added in commit b4900c0e.
> 
> Sorry, but I prefer this solution better:
> https://lists.gnu.org/archive/html/qemu-devel/2014-07/msg01595.html

Fine with me, as long as my 'make check' gets fixed. :-)

Kevin

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2014-07-10  8:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-09 14:14 [Qemu-devel] [PATCH for-2.1] test-string-output-visitor: Fix unterminated string Kevin Wolf
2014-07-10  1:41 ` Eric Blake
2014-07-10  8:00   ` Kevin Wolf

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.