summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2018-07-16 13:02:24 +0200
committerLubomir Rintel <lkundrak@v3.sk>2018-10-22 18:15:25 +0200
commitf42c3d6653e7ba54f57850f9733bcc65758947c2 (patch)
treea5a43cdff892272c5c7576e85d920abab99d748b
parent3dfb72b92687131a030a1c19e21f29ac26c26a32 (diff)
downloadNetworkManager-f42c3d6653e7ba54f57850f9733bcc65758947c2.tar.gz
service-plugin: add a warning here and there
We're basically rather careless when parsing the auth-dialog protocol. Let's add some warning so we get an early alert when something's wrong.
-rw-r--r--libnm/nm-vpn-service-plugin.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libnm/nm-vpn-service-plugin.c b/libnm/nm-vpn-service-plugin.c
index 94a1ebbc04..8d6c43a260 100644
--- a/libnm/nm-vpn-service-plugin.c
+++ b/libnm/nm-vpn-service-plugin.c
@@ -843,25 +843,37 @@ nm_vpn_service_plugin_read_vpn_details (int fd,
/* finish marker */
break;
} else if (strncmp (line->str, DATA_KEY_TAG, strlen (DATA_KEY_TAG)) == 0) {
- if (key != NULL)
+ if (key != NULL) {
+ g_warning ("a value expected");
g_string_free (key, TRUE);
+ }
key = g_string_new (line->str + strlen (DATA_KEY_TAG));
str = key;
hash = data;
} else if (strncmp (line->str, DATA_VAL_TAG, strlen (DATA_VAL_TAG)) == 0) {
if (val != NULL)
g_string_free (val, TRUE);
+ if (val || !key || hash != data) {
+ g_warning ("%s not preceded by %s", DATA_VAL_TAG, DATA_KEY_TAG);
+ break;
+ }
val = g_string_new (line->str + strlen (DATA_VAL_TAG));
str = val;
} else if (strncmp (line->str, SECRET_KEY_TAG, strlen (SECRET_KEY_TAG)) == 0) {
- if (key != NULL)
+ if (key != NULL) {
+ g_warning ("a value expected");
g_string_free (key, TRUE);
+ }
key = g_string_new (line->str + strlen (SECRET_KEY_TAG));
str = key;
hash = secrets;
} else if (strncmp (line->str, SECRET_VAL_TAG, strlen (SECRET_VAL_TAG)) == 0) {
if (val != NULL)
g_string_free (val, TRUE);
+ if (val || !key || hash != secrets) {
+ g_warning ("%s not preceded by %s", SECRET_VAL_TAG, SECRET_KEY_TAG);
+ break;
+ }
val = g_string_new (line->str + strlen (SECRET_VAL_TAG));
str = val;
}