git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] ref-filter.c: don't stomp on memory

From
Ramsay Jones <ramsay@ramsayjones.plus.com>
Date
Feb 7, 2016, 00:23 UTC
Message-ID
<56B68E73.2050303@ramsayjones.plus.com>
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
Hi Karthik,

If you need to re-roll your 'kn/ref-filter-atom-parsing' branch, could you please squash this (or something like it) into the relevant patch (commit 6613d5f1, "ref-filter: introduce parsing functions for each valid atom", 31-01-2016).

This evening, (by mistake!) I built the pu branch with -fsanitize=address in my CFLAGS. This resulted in many test failures, which were all caused by the memcmp() call below stomping all over memory.

Hmm, as I was writing this email, I had a vague recollection of another email on the list recently mentioning this code. So, if this has already been reported, sorry for the noise!

ATB, Ramsay Jones

 ref-filter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ref-filter.c b/ref-filter.c
index d48e2a3..c98065e 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -260,7 +260,8 @@ int parse_ref_filter_atom(const char *atom, const char *ep)
 		 * table.
 		 */
 		arg = memchr(sp, ':', ep - sp);
-		if ((!arg || len == arg - sp) &&
+		if ((( arg && len == arg - sp)  ||
+		     (!arg && len == ep - sp )) &&
 		    !memcmp(valid_atom[i].name, sp, len))
 			break;
 	}
-- 
2.7.0
Next: Eric Sunshine
Message 1 of 3 in “ref-filter.c: don't stomp on memory”
  1. ref-filter.c: don't stomp on memoryRamsay Jones, Feb 7, 2016
  2. Eric SunshineFeb 7, 2016
  3. Karthik NayakFeb 7, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.