The vulnerability CVE-2024-6874 occurs when libcurl, built with the macidn backend, processes an IDN name that converts to exactly 256 bytes. The introducing commit add22feeef07858307be57 added two functions, mac_idn_to_ascii and mac_ascii_to_idn, in lib/idn.c. Both functions use a 256-byte stack buffer (char buffer[256]). They call uidna_nameToASCII_UTF8 and uidna_nameToUnicodeUTF8 respectively, passing sizeof(buffer) (which is 256) as the buffer length. If the conversion results in exactly 256 bytes, the buffer is filled without a null terminator. The subsequent strdup(buffer) then reads this non-null-terminated buffer, potentially including adjacent data from the stack. The fixing commit 686d54baf1df6e0775 changes the length argument to sizeof(buffer) - 1, ensuring space for null termination. Therefore, mac_idn_to_ascii and mac_ascii_to_idn are the functions directly responsible for the vulnerable buffer handling.