about summary refs log tree commit diff
path: root/elf/dl-misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'elf/dl-misc.c')
-rw-r--r--elf/dl-misc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/elf/dl-misc.c b/elf/dl-misc.c
index ab883acb3c..364940b23f 100644
--- a/elf/dl-misc.c
+++ b/elf/dl-misc.c
@@ -135,6 +135,7 @@ _dl_debug_vdprintf (int fd, int tag_p, const char *fmt, va_list arg)
 	  /* It is a format specifier.  */
 	  char fill = ' ';
 	  int width = -1;
+	  int prec = -1;
 #if LONG_MAX != INT_MAX
 	  int long_mod = 0;
 #endif
@@ -154,6 +155,13 @@ _dl_debug_vdprintf (int fd, int tag_p, const char *fmt, va_list arg)
 	      ++fmt;
 	    }
 
+	  /* Handle precision.  */
+	  if (*fmt == '.' && fmt[1] == '*')
+	    {
+	      prec = va_arg (arg, int);
+	      fmt += 2;
+	    }
+
 	  /* Recognize the l modifier.  It is only important on some
 	     platforms where long and int have a different size.  We
 	     can use the same code for size_t.  */
@@ -202,6 +210,8 @@ _dl_debug_vdprintf (int fd, int tag_p, const char *fmt, va_list arg)
 	      /* Get the string argument.  */
 	      iov[niov].iov_base = va_arg (arg, char *);
 	      iov[niov].iov_len = strlen (iov[niov].iov_base);
+	      if (prec != -1)
+		iov[niov].iov_len = MIN (prec, iov[niov].iov_len );
 	      ++niov;
 	      break;