Commit 9bc33a68 authored by Thomas Haller's avatar Thomas Haller
Browse files

libnm: fix endless loop in nm_vpn_service_plugin_read_vpn_details()

Previously, a "DONE\n" was required to break the loop.
parent 21f94e92
......@@ -810,15 +810,14 @@ nm_vpn_service_plugin_read_vpn_details (int fd,
errno = 0;
nr = read (fd, &c, 1);
if (nr == -1) {
if (nr < 0) {
if (errno == EAGAIN) {
g_usleep (100);
continue;
}
break;
}
if (c != '\n') {
if (nr > 0 && c != '\n') {
g_string_append_c (line, c);
continue;
}
......@@ -879,6 +878,9 @@ nm_vpn_service_plugin_read_vpn_details (int fd,
}
g_string_truncate (line, 0);
if (nr == 0)
break;
}
if (success) {
......
......@@ -2295,12 +2295,12 @@ _do_read_vpn_details_impl1 (const char *file,
static void
test_nm_vpn_service_plugin_read_vpn_details (void)
{
//_do_read_vpn_details_empty ("");
//_do_read_vpn_details_empty ("hallo");
//_do_read_vpn_details_empty ("DONE");
_do_read_vpn_details_empty ("");
_do_read_vpn_details_empty ("hallo");
_do_read_vpn_details_empty ("DONE");
_do_read_vpn_details_empty ("DONE\n");
//_do_read_vpn_details_empty ("DONE\0");
//_do_read_vpn_details_empty ("\0DONE\0");
_do_read_vpn_details_empty ("DONE\0");
_do_read_vpn_details_empty ("\0DONE\0");
_do_read_vpn_details (""
"DATA_KEY=some-key\n"
......@@ -2375,7 +2375,6 @@ test_nm_vpn_service_plugin_read_vpn_details (void)
"=can have\n"
"=continuations too\n"
"SECRET_VAL=value\n"
"DONE\n"
"",
READ_VPN_DETAIL_DATA (
{ "some-key", "string\ncontinued after a line break" },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment