mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-24 16:10:45 +02:00
libnm: handle NUL characters in nm_vpn_service_plugin_read_vpn_details() and fix test
We expect to read NUL terminated strings. Upon NUL, we should do
something. Treat it as a line break.
Fixes: 8ae9cf4698 ('Revert "libnm: buffer reads in nm_vpn_service_plugin_read_vpn_details()"')
This commit is contained in:
parent
8ae9cf4698
commit
6235815248
2 changed files with 14 additions and 2 deletions
|
|
@ -795,6 +795,12 @@ nm_vpn_service_plugin_read_vpn_details(int fd, GHashTable **out_data, GHashTable
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (nr > 0 && c == '\0') {
|
||||
/* '\0' are not supported. Replace with newline. */
|
||||
c = '\n';
|
||||
}
|
||||
|
||||
if (nr > 0 && c != '\n') {
|
||||
g_string_append_c(line, c);
|
||||
if (line->len > 512 * 1024) {
|
||||
|
|
|
|||
|
|
@ -2550,8 +2550,14 @@ test_nm_vpn_service_plugin_read_vpn_details(void)
|
|||
"DONE\n"
|
||||
"\n"
|
||||
"",
|
||||
READ_VPN_DETAIL_DATA({"some\nkey-2", "val2"}, {"some-key", "string"}, ),
|
||||
READ_VPN_DETAIL_DATA(), );
|
||||
READ_VPN_DETAIL_DATA({"some\nkey-2", "val2"},
|
||||
{"some-key", "string"},
|
||||
{"key3\nkey-2", "val3"}, ),
|
||||
READ_VPN_DETAIL_DATA({"some-secret", "val3"},
|
||||
{"key-inval", "in\xc1val"},
|
||||
{"ke\xc0yx", "inval"},
|
||||
{"keyx", ""},
|
||||
{"", "val3"}), );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue