diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-10-10 08:48:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-10-10 08:48:38 +0000 |
commit | 14bcae1344091400e419fd9896024a290792ee41 (patch) | |
tree | 0cf1088a2fe200cf13cadfadb0da1d10401bfd76 /lib.c | |
parent | Releasing debian version 4.2+20230508-7. (diff) | |
download | mdadm-14bcae1344091400e419fd9896024a290792ee41.tar.xz mdadm-14bcae1344091400e419fd9896024a290792ee41.zip |
Merging upstream version 4.2+20230901.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -585,3 +585,22 @@ int parse_num(int *dest, const char *num) *dest = temp; return 0; } + +/** + * s_gethostname() - secure get hostname. Assure null-terminated string. + * + * @buf: buffer for hostname. + * @buf_len: buffer length. + * + * Return: gethostname() result. + */ +int s_gethostname(char *buf, int buf_len) +{ + assert(buf); + + int ret = gethostname(buf, buf_len); + + buf[buf_len - 1] = 0; + + return ret; +} |