pgsql: Avoid use of non-portable strnlen() in pgstat_clip_activity().

Started by Andres Freundalmost 9 years ago2 messagescomitters
Jump to latest
#1Andres Freund
andres@anarazel.de

Avoid use of non-portable strnlen() in pgstat_clip_activity().

The use of strnlen rather than strlen was just paranoia. Instead of
giving up on the paranoia, just implement the safeguard
differently. And add a comment explaining why we're careful.

Author: Andres Freund
Discussion: /messages/by-id/E1duOkJ-0001Mc-U5@gemulon.postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/71edbb6f66f7139d6209334ef8734a122ba06b56

Modified Files
--------------
src/backend/postmaster/pgstat.c | 25 +++++++++++++++++++++----
src/include/pgstat.h | 2 +-
2 files changed, 22 insertions(+), 5 deletions(-)

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#2Robert Haas
robertmhaas@gmail.com
In reply to: Andres Freund (#1)
Re: pgsql: Avoid use of non-portable strnlen() in pgstat_clip_activity().

On Tue, Sep 19, 2017 at 5:27 PM, Andres Freund <andres@anarazel.de> wrote:

Avoid use of non-portable strnlen() in pgstat_clip_activity().

The use of strnlen rather than strlen was just paranoia. Instead of
giving up on the paranoia, just implement the safeguard
differently. And add a comment explaining why we're careful.

Author: Andres Freund
Discussion: /messages/by-id/E1duOkJ-0001Mc-U5@gemulon.postgresql.org

I think it should say a NUL byte or a \0 byte, not a NULL byte. NULL
is a pointer value.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers