mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 17:48:21 +00:00
Merge remote-tracking branch 'origin/topic/dnthayer/fix-rdp'
* origin/topic/dnthayer/fix-rdp: Fix initialization of a pointer in RDP analyzer
This commit is contained in:
commit
f8323837fa
4 changed files with 24 additions and 5 deletions
5
CHANGES
5
CHANGES
|
@ -1,4 +1,9 @@
|
||||||
|
|
||||||
|
2.4-117 | 2015-08-30 22:16:24 -0700
|
||||||
|
|
||||||
|
* Fix initialization of a pointer in RDP analyzer. (Daniel
|
||||||
|
Thayer/Robin Sommer)
|
||||||
|
|
||||||
2.4-115 | 2015-08-30 21:57:35 -0700
|
2.4-115 | 2015-08-30 21:57:35 -0700
|
||||||
|
|
||||||
* Enable Bro to leverage packet fanout mode on Linux. (Kris
|
* Enable Bro to leverage packet fanout mode on Linux. (Kris
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
2.4-115
|
2.4-117
|
||||||
|
|
|
@ -91,6 +91,8 @@
|
||||||
targetEnd. Note: the end pointers are *after* the last item: e.g.
|
targetEnd. Note: the end pointers are *after* the last item: e.g.
|
||||||
*(sourceEnd - 1) is the last item.
|
*(sourceEnd - 1) is the last item.
|
||||||
|
|
||||||
|
!!! NOTE: The source and end pointers must be aligned properly !!!
|
||||||
|
|
||||||
The return result indicates whether the conversion was successful,
|
The return result indicates whether the conversion was successful,
|
||||||
and if not, whether the problem was in the source or target buffers.
|
and if not, whether the problem was in the source or target buffers.
|
||||||
(Only the first encountered problem is indicated.)
|
(Only the first encountered problem is indicated.)
|
||||||
|
@ -199,18 +201,22 @@ ConversionResult ConvertUTF8toUTF32(
|
||||||
const UTF8** sourceStart, const UTF8* sourceEnd,
|
const UTF8** sourceStart, const UTF8* sourceEnd,
|
||||||
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
|
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
|
/* NOTE: The source and end pointers must be aligned properly. */
|
||||||
ConversionResult ConvertUTF16toUTF8 (
|
ConversionResult ConvertUTF16toUTF8 (
|
||||||
const UTF16** sourceStart, const UTF16* sourceEnd,
|
const UTF16** sourceStart, const UTF16* sourceEnd,
|
||||||
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
|
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
|
/* NOTE: The source and end pointers must be aligned properly. */
|
||||||
ConversionResult ConvertUTF32toUTF8 (
|
ConversionResult ConvertUTF32toUTF8 (
|
||||||
const UTF32** sourceStart, const UTF32* sourceEnd,
|
const UTF32** sourceStart, const UTF32* sourceEnd,
|
||||||
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
|
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
|
/* NOTE: The source and end pointers must be aligned properly. */
|
||||||
ConversionResult ConvertUTF16toUTF32 (
|
ConversionResult ConvertUTF16toUTF32 (
|
||||||
const UTF16** sourceStart, const UTF16* sourceEnd,
|
const UTF16** sourceStart, const UTF16* sourceEnd,
|
||||||
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
|
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
|
||||||
|
|
||||||
|
/* NOTE: The source and end pointers must be aligned properly. */
|
||||||
ConversionResult ConvertUTF32toUTF16 (
|
ConversionResult ConvertUTF32toUTF16 (
|
||||||
const UTF32** sourceStart, const UTF32* sourceEnd,
|
const UTF32** sourceStart, const UTF32* sourceEnd,
|
||||||
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
|
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
|
||||||
|
|
|
@ -9,9 +9,8 @@ refine flow RDP_Flow += {
|
||||||
function utf16_to_utf8_val(utf16: bytestring): StringVal
|
function utf16_to_utf8_val(utf16: bytestring): StringVal
|
||||||
%{
|
%{
|
||||||
std::string resultstring;
|
std::string resultstring;
|
||||||
size_t widesize = utf16.length();
|
|
||||||
|
|
||||||
size_t utf8size = 3 * widesize + 1;
|
size_t utf8size = (3 * utf16.length() + 1);
|
||||||
|
|
||||||
if ( utf8size > resultstring.max_size() )
|
if ( utf8size > resultstring.max_size() )
|
||||||
{
|
{
|
||||||
|
@ -20,8 +19,16 @@ refine flow RDP_Flow += {
|
||||||
}
|
}
|
||||||
|
|
||||||
resultstring.resize(utf8size, '\0');
|
resultstring.resize(utf8size, '\0');
|
||||||
const UTF16* sourcestart = reinterpret_cast<const UTF16*>(utf16.begin());
|
|
||||||
const UTF16* sourceend = sourcestart + widesize;
|
// 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.
|
||||||
|
memcpy(utf16_copy, utf16.begin(), utf16.length());
|
||||||
|
|
||||||
|
char* utf16_copy_end = reinterpret_cast<const char*>(utf16_copy) + utf16.length();
|
||||||
|
const UTF16* sourcestart = utf16_copy;
|
||||||
|
const UTF16* sourceend = reinterpret_cast<UTF16*>(utf16_copy_end);
|
||||||
|
|
||||||
UTF8* targetstart = reinterpret_cast<UTF8*>(&resultstring[0]);
|
UTF8* targetstart = reinterpret_cast<UTF8*>(&resultstring[0]);
|
||||||
UTF8* targetend = targetstart + utf8size;
|
UTF8* targetend = targetstart + utf8size;
|
||||||
|
|
||||||
|
@ -37,6 +44,7 @@ refine flow RDP_Flow += {
|
||||||
}
|
}
|
||||||
|
|
||||||
*targetstart = 0;
|
*targetstart = 0;
|
||||||
|
|
||||||
// We're relying on no nulls being in the string.
|
// We're relying on no nulls being in the string.
|
||||||
return new StringVal(resultstring.c_str());
|
return new StringVal(resultstring.c_str());
|
||||||
%}
|
%}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue