Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #106248
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
| Newsgroups | comp.lang.c |
| Subject | Re: openssh do_log function has larger than needed buffer? |
| Date | Thu, 16 Mar 2017 14:25:59 +0000 |
| Organization | A noiseless patient Spider |
| Lines | 30 |
| Message-ID | <874lytti14.fsf@bsb.me.uk> (permalink) |
| References | <chx8to6l3qh.fsf@iceland.freeshell.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | mx02.eternal-september.org; posting-host="368b5322df020f7350229613c200b4e1"; logging-data="13457"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18M6wHLT4ahtFa7xGEuG9MERg+GiVWVGzY=" |
| Cancel-Lock | sha1:sANBbao6ECcXmKn/vQXG4PhtxfE= sha1:naoDELugTzdH6cgYZUoepV5a3Kg= |
| X-BSB-Auth | 1.941cdb0dcbc66c8ff54a.20170316142559GMT.874lytti14.fsf@bsb.me.uk |
| Xref | csiph.com comp.lang.c:106248 |
Show key headers only | View raw
Mike Small <smallm@sdf.org> writes: > I was looking at a function in OpenSSH that prepares a string for > logging and calls syslog with a format string limiting the length of > what is written. I'm puzzled by the difference between the size of the > char array used to compose the string (1024 bytes) and the limit on the > number of its characters that could be output by syslog (format > specifier "%.500s"). It looks like maybe a hang-over from when the code had hand-coded sizes. Or maybe there was a reason to further limit the logging via routes? Hard to say. > The only potential explanation I could think of was that it might have > something to do with multibyte strings, that maybe a string could be > devised such that the buffer would overrun from use of characters > encoded by more than one byte. But looking at the function calls before > the syslog call I'm thinking the string should be guaranteed to be nul > terminated, which I think prevents overrun even if there are multibyte > characters included. Yup. It can't be that. I think it's just an accident. But if you want a belt-and-braces approach, put a null at the end of the array just before using %s and you can be sure the logging function won't read beyond that. <snip> -- Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
openssh do_log function has larger than needed buffer? Mike Small <smallm@sdf.org> - 2017-03-15 19:49 +0000 Re: openssh do_log function has larger than needed buffer? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-16 14:25 +0000
csiph-web