mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-28 05:10:32 +01: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()"') (cherry picked from commit6235815248)
This commit is contained in:
parent
78a5c72ed6
commit
cb70a15fd5
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) {
|
||||
|
|
|
|||
|
|
@ -2546,8 +2546,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