wiretap: Fix pcapng UTF-8 validation
g_utf_8_make_valid() replaces embedded NULs with unicode replacement characters and this behaviour does not match the pcapng spec; the first NULL should terminate the string instead. Use ws_utf8_make_valid() which provides the correct behaviour.
This commit is contained in:
parent
9feb85ce4d
commit
7a33d04056
|
@ -28,6 +28,7 @@
|
|||
#include <wsutil/glib-compat.h>
|
||||
#include <wsutil/ws_assert.h>
|
||||
#include <wsutil/ws_roundup.h>
|
||||
#include <wsutil/unicode-utils.h>
|
||||
|
||||
#include "wtap-int.h"
|
||||
#include "file_wrappers.h"
|
||||
|
@ -761,10 +762,7 @@ pcapng_process_string_option(wtapng_block_t *wblock, guint16 option_code,
|
|||
char *str;
|
||||
|
||||
/* Validate UTF-8 encoding. */
|
||||
if (g_utf8_validate(opt, optlen, NULL))
|
||||
str = g_strndup(opt, optlen);
|
||||
else
|
||||
str = g_utf8_make_valid(opt, optlen);
|
||||
str = ws_utf8_make_valid(NULL, opt, optlen);
|
||||
|
||||
wtap_block_add_string_option_owned(wblock->block, option_code, str);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue