Please use strlcpy instead of strcpy - and the -1 on the buffer size is spurious (unless you follow this line with format_rewrite[CF_BUFSIZE-1] = '\0' to fix *one* of strncpy()'s deficiencies).  With strncpy, you aren't assured of '\0'-termination but, when there *is* enough space, it fills the rest of the buffer with '\0' bytes; if format_piece is short, that's a lot of '\0'-filling for no benefit.