Re: [PATCH 3/5] evaluate: check variadic argument types against formatting info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21/10/2019 12:47, Luc Van Oostenryck wrote:
On Mon, Oct 21, 2019 at 12:01:30AM +0200, Luc Van Oostenryck wrote:
On Wed, Sep 25, 2019 at 11:00:13AM +0100, Ben Dooks wrote:
+static void evaluate_format_printf(const char *fmt_string, struct symbol *fn, struct expression_list *head)
+{
+	struct format_state state = { };
+	struct expression *expr;
+
+	expr = get_expression_n(head, fn->ctype.printf_msg-1);
+	if (!expr)
+		return;
+
+	state.expr = expr;
+	state.va_start = fn->ctype.printf_va_start;
+	state.arg_index = fn->ctype.printf_va_start;
+
+	if (!fmt_string) {
+		warning(expr->pos, "not a format string?");
+	} else {
+		const char *string = fmt_string;
+		int fail = 0;
+
+		for (; string[0] != '\0'; string++) {
+			if (string[0] != '%')
+				continue;
+			if (parse_format_printf(&string, &state, head) < 0)
+				fail++;
+			string--;

This last statement is wrong, it just needs to be removed.

It's more subtle than that: the string++ should only be done
when stripping the chars before the '%'.
Thus the loop should be something like:
		while (string[0]) {
			if (string[0] != '%') {
				// strip everything before '%'
				string++;
				continue;
			}
			if (parse_format_printf(&string, &state, head) < 0)
				fail++;
		}

ok, will make this change and test.


--
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux