[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nmh-workers] strncpy(3), die, die, die.
From: |
Ralph Corderoy |
Subject: |
Re: [Nmh-workers] strncpy(3), die, die, die. |
Date: |
Sat, 29 Oct 2016 23:58:28 +0100 |
Hi Paul,
> > What if benign truncations were trunccpy(), instead of the strncpy
> > dance where the reader is unsure if it's benign or not
>
> as long as every trunccpy() result is checked, so that if truncation
> does occur there is a different code path following the call
They don't need to be checked because they're only used in those cases
where truncation, but still NUL-terminated, is valid. Kind of like when
`%.42s' is used in a lexer error message in case the token is runaway,
or 'cut -c 42'. Ken's saying that some of them are like that, e.g.
feeding back unknown errors from outside. And the function's comment
would make their intended use case very clear.
> i use asprintf() for this kind of thing.
It's nice, but it might do the formatting work twice, and the return
value needs checking, not just for "out of memory" errors, the char** is
not guaranteed to be NULL on error with GNU, and that checking conflicts
with the "minimal call-site change" that's my aim.
--
Cheers, Ralph.
https://plus.google.com/+RalphCorderoy
- Re: [Nmh-workers] strncpy(3), die, die, die., (continued)
- Re: [Nmh-workers] strncpy(3), die, die, die., Steffen Nurpmeso, 2016/10/25
- Re: [Nmh-workers] strncpy(3), die, die, die., Paul Vixie, 2016/10/25
- Re: [Nmh-workers] strncpy(3), die, die, die., Ralph Corderoy, 2016/10/29
- Re: [Nmh-workers] strncpy(3), die, die, die., Steffen Nurpmeso, 2016/10/29
- Re: [Nmh-workers] strncpy(3), die, die, die., Ralph Corderoy, 2016/10/29
- Re: [Nmh-workers] strncpy(3), die, die, die., Ken Hornstein, 2016/10/29
- Re: [Nmh-workers] strncpy(3), die, die, die., Ralph Corderoy, 2016/10/29
- Re: [Nmh-workers] strncpy(3), die, die, die., Ralph Corderoy, 2016/10/29
- Re: [Nmh-workers] strncpy(3), die, die, die., Ken Hornstein, 2016/10/29
- Re: [Nmh-workers] strncpy(3), die, die, die., Paul Vixie, 2016/10/29
- Re: [Nmh-workers] strncpy(3), die, die, die.,
Ralph Corderoy <=
- Re: [Nmh-workers] strncpy(3), die, die, die., Paul Vixie, 2016/10/29
- Re: [Nmh-workers] strncpy(3), die, die, die., Lyndon Nerenberg, 2016/10/29
- Re: [Nmh-workers] strncpy(3), die, die, die., Ken Hornstein, 2016/10/30
- Re: [Nmh-workers] strncpy(3), die, die, die., Ken Hornstein, 2016/10/24
- Re: [Nmh-workers] strncpy(3), die, die, die., Lyndon Nerenberg, 2016/10/24
Re: [Nmh-workers] strncpy(3), die, die, die., David Levine, 2016/10/24
Re: [Nmh-workers] strncpy(3), die, die, die., P Vixie, 2016/10/24
- Re: [Nmh-workers] strncpy(3), die, die, die., Anthony J. Bentley, 2016/10/24
- Re: [Nmh-workers] strncpy(3), die, die, die., P Vixie, 2016/10/24
- Prev by Date:
Re: [Nmh-workers] strncpy(3), die, die, die.
- Next by Date:
Re: [Nmh-workers] strncpy(3), die, die, die.
- Previous by thread:
Re: [Nmh-workers] strncpy(3), die, die, die.
- Next by thread:
Re: [Nmh-workers] strncpy(3), die, die, die.
- Index(es):