[Ltrace-devel] patch : disable broken printf length

Mike Dupont jamesmikedupont at googlemail.com
Fri Nov 13 13:01:37 UTC 2015


Ok, I am not sure if we even need the  future_length at all anymore,
leaving that in.
please review.

On Fri, Nov 13, 2015 at 7:49 AM, Mike  Dupont
<jamesmikedupont at googlemail.com> wrote:
> yes, need to revise the comments. I though as much, I have to redo not
> edit the patch.
>
> On Fri, Nov 13, 2015 at 7:44 AM, Petr Machata <pmachata at gmail.com> wrote:
>> BTW, I dropped the Debian bugbot from CC.
>>
>> Mike  Dupont <jamesmikedupont at googlemail.com> writes:
>>
>>> @@ -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.  */
>>
>> I don't understand the intention behind this commentary change.
>> (Also, s/Length/length/.)
>>
>>>              if (self->future_length == NULL)
>>>                  /* This should really be an assert,
>>>                   * but we can't just fail on invalid
>>> @@ -229,8 +224,6 @@ 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;
>>
>> The comment is not accurate anymore.  I think you can move all the
>> numeric cases up in the switch alongside the '#', ' ' etc.
>>
>> Looks good otherwise.
>>
>> Thanks,
>> Petr
>
>
>
> --
> 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



-- 
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
-------------- next part --------------
Index: ltrace-0.7.3/printf.c
===================================================================
--- ltrace-0.7.3.orig/printf.c
+++ ltrace-0.7.3/printf.c
@@ -97,10 +97,10 @@ 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)
 {
 
 	/* XXX note: Some types are wrong because we lack
 	   ARGTYPE_LONGLONG, ARGTYPE_UCHAR and ARGTYPE_SCHAR.  */
 	assert(lng <= 2);
@@ -130,41 +128,8 @@ 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;
-		}
+                node = expr_node_zero();
+                own_node = 0;
 		assert(node != NULL);
 
 		type_init_array(array, elt_info, 0, node, own_node);
@@ -188,8 +153,6 @@ 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;
 	struct lens *lens = NULL;
 
 	for (; self->ptr < self->end; ++self->ptr) {
@@ -207,8 +170,8 @@ param_printf_next(struct param_enum *sel
 			continue;
 
 		case '*':
-			/* Length parameter given in the next
-			 * argument.  */
+			/* 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
@@ -226,11 +189,6 @@ param_printf_next(struct param_enum *sel
 		case '1': case '2': case '3':
 		case '4': case '5': case '6':
 		case '7': case '8': case '9':
-			/* 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;
 			continue;
 
 		case 'h':
@@ -329,7 +287,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;


More information about the Ltrace-devel mailing list