Attached a dirty patch to disable the broken printf max string length
code. I dont expect it to be merged but it might be a starting point
for someone experiencing the problem that I have.

Take a look at _doprnt from libiberty for an implementation. I am
wondering why we need these lengths in the parameters anyway? I would
like the raw data so.
It might be interesting to show the result of the format string applied.

see my bug report here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=804494

any feedback would be appreciated.

mike

-- 
James Michael DuPont
Kansas Linux Fest http://kansaslinuxfest.us
Free/Libre Open Source and Open Knowledge Association of Kansas
http://openkansas.us
Member of Free Libre Open Source Software Kosova http://www.flossk.org
Saving Wikipedia(tm) articles from deletion http://SpeedyDeletion.wikia.com
Index: ltrace-0.7.3/printf.c
===================================================================
--- ltrace-0.7.3.orig/printf.c
+++ ltrace-0.7.3/printf.c
@@ -97,11 +97,11 @@ drop_future_length(struct param_enum *se
 static int
 form_next_param(struct param_enum *self,
                enum arg_type format_type, enum arg_type elt_type,
-               unsigned hlf, unsigned lng, char *len_buf, size_t len_buf_len,
+               unsigned hlf, unsigned lng, 
                struct arg_type_info *infop)
 {
 
-  debug(DEBUG_FUNCTION, "form_next_param(lng=%d,len_buf=%s)", lng, len_buf);
+  debug(DEBUG_FUNCTION, "form_next_param(lng=%d)", lng);
   
        /* XXX note: Some types are wrong because we lack
           ARGTYPE_LONGLONG, ARGTYPE_UCHAR and ARGTYPE_SCHAR.  */
@@ -130,41 +130,36 @@ form_next_param(struct param_enum *self,
 
                struct expr_node *node = NULL;
                int own_node;
-               if (len_buf_len != 0
-                   || self->future_length != NULL) {
-                       struct tmp {
-                               struct expr_node node;
-                               struct arg_type_info type;
-                       };
-                       struct tmp *len = malloc(sizeof(*len));
-                       if (len == NULL) {
-                       fail:
-                               free(len);
-                               free(array);
-                               return -1;
-                       }
-
-                       len->type = *type_get_simple(ARGTYPE_LONG);
-
-                       long l;
-                       if (self->future_length != NULL) {
-                               l = *self->future_length;
-                               drop_future_length(self);
-                       } else {
-                               l = atol(len_buf);
-                       }
-
-                       expr_init_const_word(&len->node, l, &len->type, 0);
-
-                       node = build_zero_w_arg(&len->node, 1);
-                       if (node == NULL)
-                               goto fail;
-                       own_node = 1;
-
-               } else {
-                       node = expr_node_zero();
-                       own_node = 0;
-               }
+               /* if (len_buf_len != 0 */
+               /*     || self->future_length != NULL) { */
+               /*      struct tmp { */
+               /*              struct expr_node node; */
+               /*              struct arg_type_info type; */
+               /*      }; */
+               /*      struct tmp *len = malloc(sizeof(*len)); */
+               /*      if (len == NULL) { */
+               /*      fail: */
+               /*              free(len); */
+               /*              free(array); */
+               /*              return -1; */
+               /*      } */
+               /*      len->type = *type_get_simple(ARGTYPE_LONG); */
+               /*      long l; */
+               /*      if (self->future_length != NULL) { */
+               /*              l = *self->future_length; */
+               /*              drop_future_length(self); */
+               /*      } else { */
+               /*              l = atol(len_buf); */
+               /*      } */
+               /*      expr_init_const_word(&len->node, l, &len->type, 0); */
+               /*      node = build_zero_w_arg(&len->node, 1); */
+               /*      if (node == NULL) */
+               /*              goto fail; */
+               /*      own_node = 1; */
+               /* } else { */
+                node = expr_node_zero();
+                own_node = 0;
+                //}
                assert(node != NULL);
 
                type_init_array(array, elt_info, 0, node, own_node);
@@ -188,8 +183,8 @@ param_printf_next(struct param_enum *sel
        unsigned lng = 0;
        enum arg_type format_type = ARGTYPE_VOID;
        enum arg_type elt_type = ARGTYPE_VOID;
-       char len_buf[25] = {};
-       size_t len_buf_len = 0;
+       //char len_buf[25] = {};
+       //size_t len_buf_len = 0;
        struct lens *lens = NULL;
 
        for (; self->ptr < self->end; ++self->ptr) {
@@ -207,8 +202,8 @@ param_printf_next(struct param_enum *sel
                        continue;
 
                case '*':
-                       /* Length parameter given in the next
-                        * argument.  */
+                       /* Min or max Length parameter given in the next
+                        * argument depending on position.  */
                        if (self->future_length == NULL)
                                /* This should really be an assert,
                                 * but we can't just fail on invalid
@@ -229,8 +224,8 @@ param_printf_next(struct param_enum *sel
                        /* Field length likewise, but we need to parse
                         * this to attach the appropriate string
                         * length expression.  */
-                       if (len_buf_len < sizeof(len_buf) - 1)
-                               len_buf[len_buf_len++] = *self->ptr;
+                  //if (len_buf_len < sizeof(len_buf) - 1)
+                  //len_buf[len_buf_len++] = *self->ptr;
                        continue;
 
                case 'h':
@@ -329,7 +324,7 @@ param_printf_next(struct param_enum *sel
                assert(format_type != ARGTYPE_VOID);
 
                if (form_next_param(self, format_type, elt_type, hlf, lng,
-                                   len_buf, len_buf_len, infop) < 0)
+                                    infop) < 0)
                        return -1;
 
                infop->lens = lens;

Reply via email to