[getdns-users] bindata string encoding?

Robert Edmonds edmonds at debian.org
Fri Sep 4 16:38:10 UTC 2015


Willem Toorop wrote:
> I guess it is safe to fix the C library too (but secretly make sure a
> '\0' byte is still underneath; don't tell!).

By the way, there's a (little known?) printf format specifier in C
that's useful for dealing with character arrays that are not
\0-terminated.

    char data[] = { 'd', 'a', 't', 'a', };

    /* Good: prints "data". */
    printf("%.*s\n", 4, data);

    /* Bad: Accesses memory beyond the end of the array. */
    printf("%s\n", data);

-- 
Robert Edmonds
edmonds at debian.org



More information about the Users mailing list