summaryrefslogtreecommitdiffstats
path: root/src/providers/data_provider_fo.c
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2014-05-31 19:06:56 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-06-03 14:36:42 +0200
commitbf6f1b3d49e17b1adf0448c0b06e94b1e52ddffd (patch)
treed192dbd41bcdf2ed2fbab20c9ec2934c56e4d9f6 /src/providers/data_provider_fo.c
parentcf901f549abe18f32562cbe1ef7a1ef258edab1a (diff)
downloadsssd-bf6f1b3d49e17b1adf0448c0b06e94b1e52ddffd.tar.gz
sssd-bf6f1b3d49e17b1adf0448c0b06e94b1e52ddffd.tar.xz
sssd-bf6f1b3d49e17b1adf0448c0b06e94b1e52ddffd.zip
Unify usage of function gethostname
man gethostanme says: NOTES SUSv2 guarantees that "Host names are limited to 255 bytes". POSIX.1-2001 guarantees that "Host names (not including the terminating null byte) are limited to HOST_NAME_MAX bytes". On Linux, HOST_NAME_MAX is defined with the value 64, which has been the limit since Linux 1.0 (earlier kernels imposed a limit of 8 bytes). Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src/providers/data_provider_fo.c')
-rw-r--r--src/providers/data_provider_fo.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/providers/data_provider_fo.c b/src/providers/data_provider_fo.c
index 0a443c04f..ef1f0b2ed 100644
--- a/src/providers/data_provider_fo.c
+++ b/src/providers/data_provider_fo.c
@@ -259,7 +259,7 @@ errno_t be_fo_set_dns_srv_lookup_plugin(struct be_ctx *be_ctx,
const char *hostname)
{
struct fo_resolve_srv_dns_ctx *srv_ctx = NULL;
- char resolved_hostname[HOST_NAME_MAX];
+ char resolved_hostname[HOST_NAME_MAX + 1];
errno_t ret;
if (hostname == NULL) {
@@ -270,7 +270,7 @@ errno_t be_fo_set_dns_srv_lookup_plugin(struct be_ctx *be_ctx,
"gethostname() failed: [%d]: %s\n", ret, strerror(ret));
return ret;
}
- resolved_hostname[HOST_NAME_MAX-1] = '\0';
+ resolved_hostname[HOST_NAME_MAX] = '\0';
hostname = resolved_hostname;
}