Skip to content
  • Jeff King's avatar
    replace unchecked snprintf calls with heap buffers · 5b1ef2ce
    Jeff King authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    We'd prefer to avoid unchecked snprintf calls because
    truncation can lead to unexpected results.
    
    These are all cases where truncation shouldn't ever happen,
    because the input to snprintf is fixed in size. That makes
    them candidates for xsnprintf(), but it's simpler still to
    just use the heap, and then nobody has to wonder if "100" is
    big enough.
    
    We'll use xstrfmt() where possible, and a strbuf when we need
    the resulting size or to reuse the same buffer in a loop.
    
    Signed-off-by: default avatarJeff King <peff@peff.net>
    5b1ef2ce