• Jeff King's avatar
    color: add color_set helper for copying raw colors · 7ce4fb94
    Jeff King authored
    To set up default colors, we sometimes strcpy() from the
    default string literals into our color buffers. This isn't a
    bug (assuming the destination is COLOR_MAXLEN bytes), but
    makes it harder to audit the code for problematic strcpy
    Let's introduce a color_set which copies under the
    assumption that there are COLOR_MAXLEN bytes in the
    destination (of course you can call it on a smaller buffer,
    so this isn't providing a huge amount of safety, but it's
    more convenient than calling xsnprintf yourself).
    Signed-off-by: default avatarJeff King <peff@peff.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
color.c 8.12 KB