freeipa/util/ipa_hostname.h
Fraser Tweedale 3f59118ffc ipa_sam: do not modify static buffer holding fqdn
ipa_sam was modifying the buffer returned by ipa_gethostfqdn().
Subsequent calls to ipa_gethostfqdn() returned the corrupt data,
causing other operations to fail.

Update ipa_sam to copy the string and modify the copy.  Also
document this characteristic of ipa_gethostfqdn() and explain that
callers must not modify the returned data.

Part of: https://pagure.io/freeipa/issue/8501

Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
2020-10-26 17:11:19 +11:00

23 lines
717 B
C

/*
* Copyright (C) 2020 FreeIPA Contributors see COPYING for license
*/
/* FQDN host name length including trailing NULL byte
*
* This may be longer than HOST_NAME_MAX. The hostname (effectively uname()'s
* node name) is limited to 64 characters on Linux. ipa_gethostfqdn() returns
* a FQDN from NSS which can be up to 255 octets including NULL byte.
* Effectively the FQDN is 253 ASCII characters.
*/
#define IPA_HOST_FQDN_LEN 255
/* Get the host FQDN.
*
* Returns a null-terminated static char[]. The string length is
* at most IPA_HOST_FQDN_LEN - 1. The caller MUST NOT modify this
* buffer. If modification could occur, the caller MUST copy
* the string.
*/
const char*
ipa_gethostfqdn(void);