From 21e622f214a38c048c5689158bc6314a91a46e40 Mon Sep 17 00:00:00 2001 From: Blazej Kucman Date: Fri, 16 Jun 2023 21:45:55 +0200 Subject: 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 Signed-off-by: Jes Sorensen --- mdadm.h | 1 + 1 file changed, 1 insertion(+) (limited to 'mdadm.h') diff --git a/mdadm.h b/mdadm.h index 83f2cf7f..f0ceeb78 100644 --- a/mdadm.h +++ b/mdadm.h @@ -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)) -- cgit v1.2.3