]> sourceware.org Git - systemtap.git/commitdiff
Make sure user_string_n() results are always zero terminated strings.
authorMark Wielaard <mjw@redhat.com>
Mon, 27 Apr 2009 22:24:34 +0000 (00:24 +0200)
committerMark Wielaard <mjw@redhat.com>
Mon, 27 Apr 2009 22:26:52 +0000 (00:26 +0200)
* tapset/conversions.stp (user_string_n2): Explicitly null terminate
  return string.
  (user_string_n_warn): Likewise.

tapset/conversions.stp

index 70725e9d327e244313354fecd6d8f410288f7f4a..31b1682177bcc8e495fc28c73bf2201439e04140 100644 (file)
@@ -120,6 +120,8 @@ function user_string_n2:string (addr:long, n:long, err_msg:string) %{ /* pure */
                                (char __user *) (uintptr_t) THIS->addr,
                                len) < 0)
                strlcpy(THIS->__retvalue, THIS->err_msg, MAXSTRINGLEN);
+       else
+               THIS->__retvalue[len - 1] = '\0';
 %}
 
 function user_string_n_warn:string (addr:long, n:long) %{ /* pure */
@@ -137,7 +139,8 @@ function user_string_n_warn:string (addr:long, n:long) %{ /* pure */
                                (void *) (uintptr_t) THIS->addr);
                _stp_warn(CONTEXT->error_buffer);
                strlcpy (THIS->__retvalue, "<unknown>", MAXSTRINGLEN);
-       }
+       } else
+               THIS->__retvalue[len - 1] = '\0';
 %}
 
 function user_string_n_quoted:string (addr:long, n:long) %{ /* pure */
This page took 0.028857 seconds and 5 git commands to generate.