]> git.sur5r.net Git - i3/i3/blobdiff - src/cfgparse.y
Bugfix: use bufcopy instead of buf when boundary checking (Thanks thomasba)
[i3/i3] / src / cfgparse.y
index 10ca48ccf609a4d9efff608e21b6843860ada305..dc29860cda021f1f23552ed0bfce8cfaf25aa2d6 100644 (file)
@@ -358,12 +358,14 @@ void parse_file(const char *f) {
 
             /* get key/value for this variable */
             char *v_key = value, *v_value;
-            if ((v_value = strstr(value, " ")) == NULL &&
-                (v_value = strstr(value, "\t")) == NULL) {
+            if (strstr(value, " ") == NULL && strstr(value, "\t") == NULL) {
                 ELOG("Malformed variable assignment, need a value\n");
                 continue;
             }
 
+            if (!(v_value = strstr(value, " ")))
+                v_value = strstr(value, "\t");
+
             *(v_value++) = '\0';
 
             struct Variable *new = scalloc(sizeof(struct Variable));
@@ -388,7 +390,8 @@ void parse_file(const char *f) {
         int extra = (strlen(current->value) - strlen(current->key));
         char *next;
         for (next = bufcopy;
-             (next = strcasestr(bufcopy + (next - bufcopy), current->key)) != NULL;
+             next < (bufcopy + stbuf.st_size) &&
+             (next = strcasestr(next, current->key)) != NULL;
              next += strlen(current->key)) {
             *next = '_';
             extra_bytes += extra;