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

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to