Question about ssh-keygen -Y find-principals

Wiktor Kwapisiewicz wiktor at metacode.biz
Fri Mar 8 21:45:32 AEDT 2024


Hi Damien,

I've verified that slightly modifying your patch makes the problem 
disappear:

diff --git a/sshsig.c b/sshsig.c
index d50d65fe2..145bca862 100644
--- a/sshsig.c
+++ b/sshsig.c
@@ -747,7 +747,7 @@ parse_principals_key_and_options(const char *path, 
u_long linenum, char *line,

  	cp = line;
  	cp = cp + strspn(cp, " \t"); /* skip leading whitespace */
-	if (*cp == '#' || *cp == '\0')
+	if (*cp == '#' || *cp == '\0' || strcmp(cp, "\n") == 0)
  		return SSH_ERR_KEY_NOT_FOUND; /* blank or all-comment line */

  	/* format: identity[,identity...] [option[,option...]] key */

(Note the \n instead of \r)

I've also experimented with the code a bit and found out that if the 
line that skips the whitespace:
  	cp = cp + strspn(cp, " \t"); /* skip leading whitespace */

is adjusted slightly to include newline characters:

  	cp = cp + strspn(cp, " \t\n\r"); /* skip leading whitespace */
	if (*cp == '#' || *cp == '\0')   /* <- no change in this line */

then the problem also disappears.

I'd be happy to send a patch if you think one of these look reasonable.

Thanks for help!

Kind regards,
Wiktor


More information about the openssh-unix-dev mailing list