Kouhei Sutou
null+****@clear*****
Sun May 22 20:40:58 JST 2016
Kouhei Sutou 2016-05-22 20:40:58 +0900 (Sun, 22 May 2016) New Revision: 6d58cc91001d9537cb3c12a8f55a86d15ec02b3a https://github.com/groonga/groonga/commit/6d58cc91001d9537cb3c12a8f55a86d15ec02b3a Message: windows: fix a bug that grn_text_vprintf() may access out of range Modified files: lib/str.c Modified: lib/str.c (+3 -5) =================================================================== --- lib/str.c 2016-05-22 18:01:18 +0900 (29def4f) +++ lib/str.c 2016-05-22 20:40:58 +0900 (c5815c0) @@ -2515,13 +2515,13 @@ grn_text_vprintf(grn_ctx *ctx, grn_obj *bulk, const char *format, va_list args) format, copied_args); va_end(copied_args); - if (written_size < rest_size) { + if (0 <= written_size && written_size < rest_size) { is_written = GRN_TRUE; } } + if (!is_written) { #ifdef WIN32 - if (written_size == -1 && errno == ERANGE) { # define N_NEW_SIZES 3 int i; int new_sizes[N_NEW_SIZES]; @@ -2548,9 +2548,7 @@ grn_text_vprintf(grn_ctx *ctx, grn_obj *bulk, const char *format, va_list args) } } # undef N_NEW_SIZES - } #else /* WIN32 */ - if (!is_written) { grn_rc rc; int required_size = written_size + 1; /* "+ 1" for terminate '\0'. */ @@ -2560,8 +2558,8 @@ grn_text_vprintf(grn_ctx *ctx, grn_obj *bulk, const char *format, va_list args) } written_size = vsnprintf(GRN_BULK_CURR(bulk), required_size, format, args); - } #endif /* WIN32 */ + } if (written_size < 0) { return GRN_INVALID_ARGUMENT; -------------- next part -------------- HTML����������������������������... 下载