diff options
author | Blazej Kucman <blazej.kucman@intel.com> | 2023-06-16 21:45:55 +0200 |
---|---|---|
committer | Jes Sorensen <jes@trained-monkey.org> | 2023-09-01 17:38:44 +0200 |
commit | 21e622f214a38c048c5689158bc6314a91a46e40 (patch) | |
tree | 1767839540cfe77cdf669686a81a6e010a561ce1 /mdadm.h | |
parent | imsm: fix free space calculations (diff) | |
download | mdadm-21e622f214a38c048c5689158bc6314a91a46e40.tar.xz mdadm-21e622f214a38c048c5689158bc6314a91a46e40.zip |
Add secure gethostname() wrapper
gethostname() func does not ensure null-terminated string
if hostname is longer than buffer length.
For security, a function s_gethostname() has been added
to ensure that "\0" is added to the end of the buffer.
Previously this had to be handled in each place
of the gethostname() call.
Signed-off-by: Blazej Kucman <blazej.kucman@intel.com>
Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
Diffstat (limited to 'mdadm.h')
-rw-r--r-- | mdadm.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -1805,6 +1805,7 @@ extern void set_dlm_hooks(void); extern void sleep_for(unsigned int sec, long nsec, bool wake_after_interrupt); extern bool is_directory(const char *path); extern bool is_file(const char *path); +extern int s_gethostname(char *buf, int buf_len); #define _ROUND_UP(val, base) (((val) + (base) - 1) & ~(base - 1)) #define ROUND_UP(val, base) _ROUND_UP(val, (typeof(val))(base)) |