[Top][All Lists]

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

[Qemu-commits] [qemu/qemu] 9e99c5: tests: Fix unterminated string output

From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 9e99c5: tests: Fix unterminated string output visitor enum...
Date: Thu, 10 Jul 2014 06:30:04 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 9e99c5fd7060267a0331d900e73fdb36047bfe0c
  Author: Andreas Färber <address@hidden>
  Date:   2014-07-10 (Thu, 10 Jul 2014)

  Changed paths:
    M tests/test-string-output-visitor.c

  Log Message:
  tests: Fix unterminated string output visitor enum human string

The buffer was being allocated of size string length plus two.
Around the string two quotes were being added, but no terminating NUL.
It was then compared using g_assert_cmpstr(), resulting in fairly random
assertion failures:

 ERROR:tests/test-string-output-visitor.c:213:test_visitor_out_enum: assertion 
failed (str == str_human): ("\"value1\"" == "\"value1\"\001EEEEEEEEEEEEEE\0171")

There is no g_assert_cmpnstr() counterpart, so use g_strdup_printf()
for safely assembling the string in the first place.

Cc: Hu Tao <address@hidden>
Cc: Michael S. Tsirkin <address@hidden>
Suggested-by: Eric Blake <address@hidden>
Fixes: b4900c0 tests: add human format test for string output visitor
Signed-off-by: Andreas Färber <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Hu Tao <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>

reply via email to

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