[Freeipa-devel] [PATCH 0133] ipa-cldap: Cut NetBIOS name after 15 characters
Alexander Bokovoy
abokovoy at redhat.com
Tue Nov 26 15:56:02 UTC 2013
On Tue, 26 Nov 2013, Jan Cholasta wrote:
>On 26.11.2013 16:43, Simo Sorce wrote:
>>On Tue, 2013-11-26 at 16:38 +0100, Jan Cholasta wrote:
>>>- pdc_name = talloc_asprintf(nlr, "\\\\%s", fq_hostname);
>>>+ snprintf(pdc_name, 16, "\\\\%s", fq_hostname);
>>>+ pdc_name[15] = '\0';
>>
>>It's simpler to use length qualifiers in talloc_asprintf:
>>pdc_name = talloc_asprintf(nlr, "\\\\%.*s", 15, fq_hostname);
>
>Thanks, I didn't know about that.
Right, talloc_asprintf calls vsnprint() underneath which accepts
precision marker -- either explicitly, "\\\\%.15s", or implicitly, via *
and corresponding argument.
--
/ Alexander Bokovoy
More information about the Freeipa-devel
mailing list