Re: strncpy is not a safe version of strcpy

Поиск
Список
Период
Сортировка
От Stephen Frost
Тема Re: strncpy is not a safe version of strcpy
Дата
Msg-id 20131115145324.GB17272@tamriel.snowman.net
обсуждение исходный текст
Ответ на Re: strncpy is not a safe version of strcpy  (Andres Freund <andres@2ndquadrant.com>)
Ответы Re: strncpy is not a safe version of strcpy  (Andres Freund <andres@2ndquadrant.com>)
Список pgsql-hackers
* Andres Freund (andres@2ndquadrant.com) wrote:
> FWIW, argv0 is pretty much guaranteed to be shorter than MAXPGPATH since
> MAXPGPATH is the longest a path can be, and argv[0] is either the executable's
> name (if executed via PATH) or the path to the executable.

Err, it's the longest that *we* think the path can be..  That's not the
same as actually being the longest that a path can be, which depends on
the filesystem and OS...  It's not hard to get past our 1024 limit:

sfrost@beorn:/really/long/path> echo $PWD | wc -c
1409

> Now, you could probably write a program to exeve() a binary with argv[0]
> being longer, but in that case you can also just put garbage in there.

We shouldn't blow up in that case either, really.
Thanks,
    Stephen

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: strncpy is not a safe version of strcpy
Следующее
От: Robert Haas
Дата:
Сообщение: Re: ERROR during end-of-xact/FATAL