[clug] Code question: Why doesn't this seqfault (kernel/printk.c)

Michael Still mikal at stillhq.com
Mon Oct 20 15:30:17 EST 2003

On Mon, 20 Oct 2003, Martin Pool wrote:

> The first if statement checks the value of log_level_unknown, which is
> just an auto int.  I don't see how that could segfault.
> Did you mean the second if statement?

Yeah, sorry, that's what I meant.
> printk_buf is an auto char array, so printk_buf != NULL.  printk_buf
> is written using vsnprintf() which always nul terminates.


> Perhaps it could have trouble if there is a terminated severity
> specifier just near the end of the string?
>  "......<1\0"

That was the sort of scenario I was thinking of. Anything from:
would cause the end of the string to be overrun, would it not?

> If any of the characters p[0..2] are \0, then we stop at that point,
> because the null will terminate the attempt to match against
> "<[0-7]>".  We don't read any further than the nul.

Cool. I can see that now, so I guess that was the obvious thing I was 



Michael Still (mikal at stillhq.com) | "All my life I've had one dream,
http://www.stillhq.com            |  to achieve my many goals"
UTC + 10                          |    -- Homer Simpson

More information about the linux mailing list