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

[Xen-devel] [PATCH] vsprintf: Make sure argument to %*ph/%pv is valid



If NULL pointer is passed for these specifiers then print '-'
or 'd-v-'.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
---
 xen/common/vsprintf.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c
index 065cc42..84cfa85 100644
--- a/xen/common/vsprintf.c
+++ b/xen/common/vsprintf.c
@@ -280,6 +280,13 @@ static char *pointer(char *str, char *end, const char 
**fmt_ptr,
         /* Consumed 'h' from the format string. */
         ++*fmt_ptr;
 
+        if ( hex_buffer == NULL )
+        {
+            if ( str < end )
+                *str++ = '-';
+            return str;
+        }
+
         /* Bound user count from %* to between 0 and 64 bytes. */
         if ( field_width <= 0 )
             return str;
@@ -338,6 +345,18 @@ static char *pointer(char *str, char *end, const char 
**fmt_ptr,
         ++*fmt_ptr;
         if ( str < end )
             *str = 'd';
+        if ( v == NULL )
+        {
+            /* If v is NULL then print 'd-v-' */
+            str++;
+            if ( str < end )
+                *str++ = '-';
+            if ( str < end )
+                *str++ = 'v';
+            if ( str < end )
+                *str++ = '-';
+            return str;
+        }
         str = number(str + 1, end, v->domain->domain_id, 10, -1, -1, 0);
         if ( str < end )
             *str = 'v';
-- 
1.7.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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