Brandon Casey schrieb: > Some platforms provide a horribly broken snprintf. More broken than the > platforms that return -1 when there is too little space in the target buffer > for the formatted string. Some platforms provide an snprintf which _always_ > returns the number of characters transmitted to the buffer, regardless of > whether there was enough space or not. ... > diff --git a/compat/snprintf.c b/compat/snprintf.c > index 580966e..357e733 100644 > --- a/compat/snprintf.c > +++ b/compat/snprintf.c > @@ -17,6 +17,8 @@ int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap) > > if (maxsize > 0) { > ret = vsnprintf(str, maxsize-SNPRINTF_SIZE_CORR, format, ap); > + if (ret == maxsize-1) > + ret = -1; > /* Windows does not NUL-terminate if result fills buffer */ > str[maxsize-1] = 0; > } > @@ -34,6 +36,8 @@ int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap) > break; > s = str; > ret = vsnprintf(str, maxsize-SNPRINTF_SIZE_CORR, format, ap); > + if (ret == maxsize-1) > + ret = -1; > } > free(s); > return ret; This looks good, and it passes the test suite on MinGW. Hence: Acked-by: Johannes Sixt <johannes.sixt@xxxxxxxxxx> -- Hannes -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html