summaryrefslogtreecommitdiffstats
path: root/mdadm.h
diff options
context:
space:
mode:
authorBlazej Kucman <blazej.kucman@intel.com>2023-06-16 21:45:55 +0200
committerJes Sorensen <jes@trained-monkey.org>2023-09-01 17:38:44 +0200
commit21e622f214a38c048c5689158bc6314a91a46e40 (patch)
tree1767839540cfe77cdf669686a81a6e010a561ce1 /mdadm.h
parentimsm: fix free space calculations (diff)
downloadmdadm-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.h1
1 files changed, 1 insertions, 0 deletions
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))