<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 8 Sep 2019 at 14:02, Andrew Cagney <<a href="mailto:andrew.cagney@gmail.com">andrew.cagney@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>First, does anyone know a way to first create a DN containing !isprint() and then get it past NSS - pluto should only look at certs after the've been NSS approved and NSS could be rejecting bad DNs (anyone?) which could make the below largely academic.</div><div><br></div><div>Now some background on DN/ID sanitizing.  I think things can be reduced to:</div><div><br></div><div>%.*s, len, ptr - dumps a raw string into a buffer stopping at len or NUL - this is what "raw text" means in the below</div><div>escape_metachar() replaces shell meta characters ('"...) with \NNN but leaves !isprint() alone<br></div><div>sanitize_string() replaces !isprint() with \NNN</div><div><br></div><div>dntoa() - dumps the DN as raw text<br></div><div>str_dn() - calls dntoa() and then calls sanitize_string()</div><div>idtoa() (and str_id) - dumps an ID into a buffer; but then scribbles on the result replacing !isprint() with '?'; since it calls dntoa() it applies to the raw DN</div><div>jam_id_escaped (it was called something else before): calls idtoa() so !isprint()->''?' and then escape_metachar() so '$... -> \.</div><div><br></div><div>hopefully I've got this right (and I've managed to spread the confusion :-)</div><div><br></div><div>So how is it used?</div><div><br></div><div>First there's logging.   Here I don't think it matters (just as long as !isprint() is sanitized).</div><div>For no obvious reason we've got idtoa() using '?' and str_dn() using \NNN (like sanitize_string()) - so I figure changing everything to the \NNN is harmless.</div><div><br></div><div>Next there's shell variables and here's where things get weird:</div><div><br></div><div>- .._DN='...': the code calls dntoa()+escape_metachar() which means that while shell metachars are escaped !isprint() is not - so, in theory the shell variable could contain escape characters ...</div><div>- ..._ID='...': the code calls jam_id_escaped() which means metachars get escaped and !isprint() becomes '?' - the shell variable doesn't match the content</div><div><br></div></div></blockquote><div><br></div><div>It turns out that ever since 0c9e7831570fbe1c641df16baf51446b55e63a7e in '13, escaped-metachars have been printed as (\t):<br></div><div>   \0311</div><div>instead of:</div><div>   \011</div><div>which strongly suggests that either:</div><div>- the escaping isn't happening in the real world</div><div>- it is, but the shell variables are only ever printed (they can't meaningfully be compared or used)</div><div><br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div>Anyone?  My guess is that it doesn't matter but !isprint() should probably be suppressed. The obvious choice is:</div><div>- !isprint() -> \NNN but that will trip up on shell escapes - \ would end up being escaped :-)</div><div>- metachar -> \meta - fine</div><div>but remember !isprint() is off script so the choice is arbitrary.</div><div><br></div><div>Thoughts?</div><div><br></div><div>Andrew</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>
</blockquote></div></div>