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

Re: [PATCH 1/2] gpg-interface: handle missing " with " gracefully in parse_ssh_output()

From
René Scharfe <l.s.r@web.de>
Date
Nov 1, 2021, 18:36 UTC
Message-ID
<abc4c174-f848-a0f4-3f1d-486ee8f275b2@web.de>
In-Reply-To
<dedf3971-adb1-c355-0b05-4e94ad92e1f7@gigacodes.de>
Am 01.11.21 um 09:40 schrieb Fabian Stelzer:
Show 8 quoted lines
> On 30.10.21 19:04, René Scharfe wrote:
>> Silly bonus question: What's the purpose of the "+ 1" and "- 1", which
>> seem to cancel each other out?
>
> They do. But only for the xmemdupz. It is important for the strstr() to
> skip over already found strings (" with " could be in the principal name
> as well - multiple times even). And doing strstr(line +1, ...) can be
> problematic for the first iteration.
Ah, right.
Show 5 quoted lines
>>  		do {
>>  			search = strstr(line, " with ");
>>  			if (search)
>>  				line = search + 1;
>>  		} while (search != NULL);
This can be shortened to:
		while ((search = strstr(line, " with ")))
			line = search + 1;

I still would have tripped over the +1 / -1, though. Calling an rfind() or strrstr() or find_last() function that deals with it internally would have helped me avoid that, I think, but we don't have use for such a thing anywhere else.

René
Previous: Fabian Stelzer
Message 8 of 8 in “gpg-interface: handle missing " with " gracefully in parse_ssh_output()”
  1. 1/2 gpg-interface: handle missing " with " gracefully in parse_ssh_output()René Scharfe, Oct 30, 2021
  2. 2/2 gpg-interface: avoid buffer overrun in parse_ssh_output()René Scharfe, Oct 30, 2021
  3. Junio C HamanoNov 1, 2021
  4. Fabian StelzerNov 1, 2021
  5. Junio C HamanoNov 1, 2021
  6. Junio C HamanoNov 1, 2021
  7. Fabian StelzerNov 1, 2021
  8. René ScharfeNov 1, 2021

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.