The add_domain_name code has another buffer overflow problem
const size_t size = 1024;
char *dest = malloc(size+1);
strncpy(dest, source, size);
strncat(dest, "@example.com", size);
return dest;
The first strncpy will not append a NUL character when strlen(source) is exactly equal to size; the rules for strncpy and NUL termination are just about useless outside of a few specialty cases.(heinrich5991 found a seperate problem with the strncat).
IMHO, this helps prove the point about levels of abstraction. The only reason that we argue over the idea that higher level == better is that we're programmers, and we argue over everything :-)