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

[qemu-xen master] qapi/error: Check format string argument in error_*prepend()



commit 192cf54ac5408d21c20c17b3794a632970bbb880
Author:     Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
AuthorDate: Thu Jul 23 19:12:05 2020 +0200
Commit:     Markus Armbruster <armbru@xxxxxxxxxx>
CommitDate: Fri Jul 24 15:03:09 2020 +0200

    qapi/error: Check format string argument in error_*prepend()
    
    error_propagate_prepend() "behaves like error_prepend()", and
    error_prepend() uses "formatting @fmt, ... like printf()".
    error_prepend() checks its format string argument, but
    error_propagate_prepend() does not. Fix by addint the format
    attribute to error_propagate_prepend() and error_vprepend().
    
    This would have caught the bug fixed in the previous commit.
    
    Missed in commit 4b5766488f "error: Fix use of error_prepend() with
    &error_fatal, &error_abort".
    
    Inspired-by: Stefan Weil <sw@xxxxxxxxxxx>
    Suggested-by: Eric Blake <eblake@xxxxxxxxxx>
    Reviewed-by: Stefan Weil <sw@xxxxxxxxxxx>
    Reviewed-by: Markus Armbruster <armbru@xxxxxxxxxx>
    Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
    Message-Id: <20200723171205.14949-1-philmd@xxxxxxxxxx>
    Reviewed-by: Markus Armbruster <armbru@xxxxxxxxxx>
    [Commit message tweaked]
    Signed-off-by: Markus Armbruster <armbru@xxxxxxxxxx>
---
 include/qapi/error.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/qapi/error.h b/include/qapi/error.h
index 7932594dce..eaa05c4837 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -382,13 +382,15 @@ void error_propagate(Error **dst_errp, Error *local_err);
  * Please use ERRP_GUARD() and error_prepend() instead when possible.
  */
 void error_propagate_prepend(Error **dst_errp, Error *local_err,
-                             const char *fmt, ...);
+                             const char *fmt, ...)
+    GCC_FMT_ATTR(3, 4);
 
 /*
  * Prepend some text to @errp's human-readable error message.
  * The text is made by formatting @fmt, @ap like vprintf().
  */
-void error_vprepend(Error *const *errp, const char *fmt, va_list ap);
+void error_vprepend(Error *const *errp, const char *fmt, va_list ap)
+    GCC_FMT_ATTR(2, 0);
 
 /*
  * Prepend some text to @errp's human-readable error message.
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.