xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] common/vsprintf: fix return value when formatting symbolic addresses
@ 2013-12-02 12:06 Jan Beulich
  2013-12-02 13:07 ` Andrew Cooper
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2013-12-02 12:06 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Keir Fraser

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

When the buffer to be formatted to is too small, the function return
value is expected to be the number of characters that would be printed
(particularly important if that value is then used for allocating a
buffer). Hence incrementing the active pointer must always be
independent of actually storing a character.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/common/vsprintf.c
+++ b/xen/common/vsprintf.c
@@ -294,6 +294,7 @@ static char *pointer(char *str, char *en
             /* Print '+<offset>/<len>' */
             str = number(str, end, sym_offset, 16, -1, -1, SPECIAL|SIGN|PLUS);
             if ( str <= end )
-                *str++ = '/';
+                *str = '/';
+            ++str;
             str = number(str, end, sym_size, 16, -1, -1, SPECIAL);
         }
 




[-- Attachment #2: vsprintf-symbol-retval.patch --]
[-- Type: text/plain, Size: 888 bytes --]

common/vsprintf: fix return value when formatting symbolic addresses

When the buffer to be formatted to is too small, the function return
value is expected to be the number of characters that would be printed
(particularly important if that value is then used for allocating a
buffer). Hence incrementing the active pointer must always be
independent of actually storing a character.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/common/vsprintf.c
+++ b/xen/common/vsprintf.c
@@ -294,6 +294,7 @@ static char *pointer(char *str, char *en
             /* Print '+<offset>/<len>' */
             str = number(str, end, sym_offset, 16, -1, -1, SPECIAL|SIGN|PLUS);
             if ( str <= end )
-                *str++ = '/';
+                *str = '/';
+            ++str;
             str = number(str, end, sym_size, 16, -1, -1, SPECIAL);
         }
 

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

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

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

end of thread, other threads:[~2013-12-02 15:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-02 12:06 [PATCH] common/vsprintf: fix return value when formatting symbolic addresses Jan Beulich
2013-12-02 13:07 ` Andrew Cooper
2013-12-02 15:23   ` Keir Fraser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).