diff --git a/aux/bifcl b/aux/bifcl index abfe5cb864..5a43a584e8 160000 --- a/aux/bifcl +++ b/aux/bifcl @@ -1 +1 @@ -Subproject commit abfe5cb864a17b8c06c70d4674b32a51280ee62b +Subproject commit 5a43a584e861d0fdbcdb42ef848e676dab179bd5 diff --git a/aux/binpac b/aux/binpac index 7892be3fb1..105e243ce5 160000 --- a/aux/binpac +++ b/aux/binpac @@ -1 +1 @@ -Subproject commit 7892be3fb11a458fec2c8879e862f5db987607b2 +Subproject commit 105e243ce5ad55ca28f4a6511d18d973d494dd2a diff --git a/cmake b/cmake index aa45717169..3d656738a5 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit aa45717169e44cc171efcf6abf904c5f9725d09a +Subproject commit 3d656738a538a6b3d322a09173b656c929044e2e diff --git a/src/DFA.cc b/src/DFA.cc index 071a8f9570..8135a25fa6 100644 --- a/src/DFA.cc +++ b/src/DFA.cc @@ -308,7 +308,8 @@ DFA_State* DFA_State_Cache::Lookup(const NFA_state_list& nfas, DigestStr* digest { // We assume that state ID's don't exceed 10 digits, plus // we allow one more character for the delimiter. - u_char id_tag[nfas.length() * 11 + 1]; + auto id_tag_buf = std::make_unique(nfas.length() * 11 + 1); + auto id_tag = id_tag_buf.get(); u_char* p = id_tag; for ( int i = 0; i < nfas.length(); ++i ) diff --git a/src/Debug.cc b/src/Debug.cc index 3a13a4c7f7..ef6a41f855 100644 --- a/src/Debug.cc +++ b/src/Debug.cc @@ -565,7 +565,8 @@ int dbg_execute_command(const char* cmd) delete [] localcmd; // Make sure we know this op name. - const char* matching_cmds[num_debug_cmds()]; + auto matching_cmds_buf = std::make_unique(num_debug_cmds()); + auto matching_cmds = matching_cmds_buf.get(); int num_matches = find_all_matching_cmds(opstring, matching_cmds); if ( ! num_matches ) diff --git a/src/analyzer/protocol/smb/smb-strings.pac b/src/analyzer/protocol/smb/smb-strings.pac index dc86421ed1..5d025f162a 100644 --- a/src/analyzer/protocol/smb/smb-strings.pac +++ b/src/analyzer/protocol/smb/smb-strings.pac @@ -27,12 +27,12 @@ refine connection SMB_Conn += { function uint8s_to_stringval(data: uint8[]): StringVal %{ int length = data->size(); - uint8 buf[length]; + auto buf = std::make_unique(length); for ( int i = 0; i < length; ++i) buf[i] = (*data)[i]; - const bytestring bs = bytestring(buf, length); + const bytestring bs = bytestring(buf.get(), length); return utf16_bytestring_to_utf8_val(bro_analyzer()->Conn(), bs); %} @@ -41,7 +41,7 @@ refine connection SMB_Conn += { if ( s->unicode() == false ) { int length = s->a()->size(); - char buf[length]; + auto buf = std::make_unique(length); for ( int i = 0; i < length; i++) { @@ -52,7 +52,7 @@ refine connection SMB_Conn += { if ( length > 0 && buf[length-1] == 0x00 ) length--; - return new StringVal(length, buf); + return new StringVal(length, buf.get()); } else { diff --git a/src/analyzer/protocol/socks/socks-analyzer.pac b/src/analyzer/protocol/socks/socks-analyzer.pac index 726ccb8d0a..351c4003c7 100644 --- a/src/analyzer/protocol/socks/socks-analyzer.pac +++ b/src/analyzer/protocol/socks/socks-analyzer.pac @@ -7,14 +7,14 @@ StringVal* array_to_string(vector *a); StringVal* array_to_string(vector *a) { int len = a->size(); - char tmp[len]; - char *s = tmp; + auto tmp = std::make_unique(len); + char *s = tmp.get(); for ( vector::iterator i = a->begin(); i != a->end(); *s++ = *i++ ); while ( len > 0 && tmp[len-1] == '\0' ) --len; - return new StringVal(len, tmp); + return new StringVal(len, tmp.get()); } %} diff --git a/src/analyzer/protocol/zip/ZIP.cc b/src/analyzer/protocol/zip/ZIP.cc index 4b94912e75..38d6fac2b7 100644 --- a/src/analyzer/protocol/zip/ZIP.cc +++ b/src/analyzer/protocol/zip/ZIP.cc @@ -51,7 +51,7 @@ void ZIP_Analyzer::DeliverStream(int len, const u_char* data, bool orig) return; static unsigned int unzip_size = 4096; - Bytef unzipbuf[unzip_size]; + auto unzipbuf = std::make_unique(unzip_size); int allow_restart = 1; @@ -63,7 +63,7 @@ void ZIP_Analyzer::DeliverStream(int len, const u_char* data, bool orig) while ( true ) { - zip->next_out = unzipbuf; + zip->next_out = unzipbuf.get(); zip->avail_out = unzip_size; zip_status = inflate(zip, Z_SYNC_FLUSH); @@ -75,7 +75,7 @@ void ZIP_Analyzer::DeliverStream(int len, const u_char* data, bool orig) int have = unzip_size - zip->avail_out; if ( have ) - ForwardStream(have, unzipbuf, IsOrig()); + ForwardStream(have, unzipbuf.get(), IsOrig()); if ( zip_status == Z_STREAM_END ) { diff --git a/src/binpac_bro-lib.pac b/src/binpac_bro-lib.pac index 3cc033a587..58559bf827 100644 --- a/src/binpac_bro-lib.pac +++ b/src/binpac_bro-lib.pac @@ -28,8 +28,9 @@ function utf16_bytestring_to_utf8_val(conn: Connection, utf16: bytestring): Stri // We can't assume that the string data is properly aligned // here, so make a copy. - UTF16 utf16_copy[utf16.length()]; // Twice as much memory than necessary. - memset(utf16_copy, 0, sizeof(utf16_copy)); // needs to be set to 0, otherwhise we have uninitialized memory issues when utf16.length is odd. + auto utf16_copy_buf = std::make_unique(utf16.length()); // Twice as much memory than necessary. + auto utf16_copy = utf16_copy_buf.get(); + memset(utf16_copy, 0, sizeof(UTF16) * utf16.length()); // needs to be set to 0, otherwhise we have uninitialized memory issues when utf16.length is odd. memcpy(utf16_copy, utf16.begin(), utf16.length()); const char* utf16_copy_end = reinterpret_cast(utf16_copy) + utf16.length(); diff --git a/src/util.cc b/src/util.cc index 70a53bc005..b6293307bf 100644 --- a/src/util.cc +++ b/src/util.cc @@ -1799,7 +1799,10 @@ FILE* rotate_file(const char* name, RecordVal* rotate_info) // Build file names. const int buflen = strlen(name) + 128; - char newname[buflen], tmpname[buflen+4]; + auto newname_buf = std::make_unique(buflen); + auto tmpname_buf = std::make_unique(buflen + 4); + auto newname = newname_buf.get(); + auto tmpname = tmpname_buf.get(); snprintf(newname, buflen, "%s.%d.%.06f.tmp", name, getpid(), network_time); diff --git a/src/zeek.bif b/src/zeek.bif index 896a70cceb..539c87e5d2 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -2830,7 +2830,8 @@ function bytestring_to_hexstr%(bytestring: string%): string %{ bro_uint_t len = bytestring->AsString()->Len(); const u_char* bytes = bytestring->AsString()->Bytes(); - char hexstr[(2 * len) + 1]; + auto hextr_buf = std::make_unique((2 * len) + 1); + auto hexstr = hextr_buf.get(); hexstr[0] = 0; for ( bro_uint_t i = 0; i < len; ++i ) @@ -2861,7 +2862,8 @@ function hexstr_to_bytestring%(hexstr: string%): string const char* bytes = hexstr->AsString()->CheckString(); int outlen = (len/2); - char bytestring[outlen]; + auto bytestring_buf = std::make_unique(outlen); + auto bytestring = bytestring_buf.get(); memset(bytestring, 0, outlen); for ( bro_uint_t i = 0; i < len/2; ++i )