]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: tools: provide a may_access() function and make dump_hex() use it
authorWilly Tarreau <w@1wt.eu>
Mon, 20 May 2019 14:48:20 +0000 (16:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 20 May 2019 14:59:37 +0000 (16:59 +0200)
commit371010594592b753a2c467b5d2b97f39a9f27770
treed4022eac6d47239c67929f55e6da72a7aa0ff5b8
parent6bdf3e9b111bd197ad1d933c87b6229dbd782ad1
MINOR: tools: provide a may_access() function and make dump_hex() use it

It's a bit too easy to crash by accident when using dump_hex() on any
area. Let's have a function to check if the memory may safely be read
first. This one abuses the stat() syscall checking if it returns EFAULT
or not, in which case it means we're not allowed to read from there. In
other situations it may return other codes or even a success if the
area pointed to by the file exists. It's important not to abuse it
though and as such it's tested only once per output line.
include/common/standard.h
src/debug.c
src/standard.c