]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
openvpnctrl: Fix adding firewall rules.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Sep 2011 18:37:49 +0000 (20:37 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Sep 2011 18:37:49 +0000 (20:37 +0200)
src/misc-progs/openvpnctrl.c

index 163386b43a43b5f05671e7ba5a06033d2a105572..5207c240fbc58bd87bc0ad90f5cac8082f737c0b 100644 (file)
@@ -25,7 +25,7 @@ char enableorange[STRING_SIZE] = "off";
 char OVPNRED[STRING_SIZE] = "OVPN";
 char OVPNBLUE[STRING_SIZE] = "OVPN_BLUE_";
 char OVPNORANGE[STRING_SIZE] = "OVPN_ORANGE_";
-char WRAPPERVERSION[STRING_SIZE] = "ipfire-2.2.0";
+char WRAPPERVERSION[STRING_SIZE] = "ipfire-2.2.1";
 
 struct connection_struct {
        char name[STRING_SIZE];
@@ -88,7 +88,8 @@ connection *getConnections() {
        }
 
        char line[STRING_SIZE] = "";
-       char *result;
+       char result[STRING_SIZE] = "";
+       char *resultptr;
        int count;
        connection *conn_first = NULL;
        connection *conn_last = NULL;
@@ -109,19 +110,31 @@ connection *getConnections() {
                conn_last = conn_curr;
 
                count = 0;
-               result = strtok(line, ",");
-               while (result) {
+               char *lineptr = &line;
+               while (1) {
+                       if (*lineptr == NULL)
+                               break;
+
+                       resultptr = result;
+                       while (*lineptr != NULL) {
+                               if (*lineptr == ',') {
+                                       lineptr++;
+                                       break;
+                               }
+                               *resultptr++ = *lineptr++;
+                       }
+                       *resultptr = '\0';
+
                        if (count == 2) {
                                strcpy(conn_curr->name, result);
                        } else if (count == 4) {
                                strcpy(conn_curr->type, result);
-                       } else if (count == 12) {
+                       } else if (count == 29) {
                                strcpy(conn_curr->proto, result);
-                       } else if (count == 13) {
+                       } else if (count == 30) {
                                conn_curr->port = atoi(result);
                        }
 
-                       result = strtok(NULL, ",");
                        count++;
                }
        }