| От | Tom Lane |
|---|---|
| Тема | Re: Using the return value of strlcpy() and strlcat() |
| Дата | |
| Msg-id | 6698.1552495855@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Using the return value of strlcpy() and strlcat() (ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)) |
| Ответы |
Re: Using the return value of strlcpy() and strlcat()
|
| Список | pgsql-hackers |
ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes:
> [ let's convert
> + strlcpy(buf + buflen, name, NAMEDATALEN);
> + buflen += strlen(buf + buflen);
> to
> + buflen += strlcpy(buf + buflen, name, NAMEDATALEN);
> ]
I don't think that's a safe transformation: what strlcpy returns is
strlen(src), which might be different from what it was actually
able to fit into the destination.
Sure, they're equivalent if no truncation occurred; but if we were
100.00% sure of no truncation, we'd likely not bother with strlcpy.
regards, tom lane
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера