chiark / gitweb /
switch some strlcpy's to memcpy
[elogind.git] / udev_rules_parse.c
index e708f355584ec1f73b7c6db798cbcdac6ef81011..4580a779c6be8b77b3c5ccf8805765be20890a1c 100644 (file)
@@ -1,12 +1,9 @@
 /*
  * udev_rules_parse.c
  *
- * Userspace devfs
- *
  * Copyright (C) 2003,2004 Greg Kroah-Hartman <greg@kroah.com>
  * Copyright (C) 2003-2005 Kay Sievers <kay.sievers@vrfy.org>
  *
- *
  *     This program is free software; you can redistribute it and/or modify it
  *     under the terms of the GNU General Public License as published by the
  *     Free Software Foundation version 2 of the License.
@@ -92,7 +89,7 @@ static int get_key(char **line, char **key, enum key_operation *operation, char
        char *temp;
 
        linepos = *line;
-       if (!linepos)
+       if (linepos == NULL && linepos[0] == '\0')
                return -1;
 
        /* skip whitespace */
@@ -100,7 +97,10 @@ static int get_key(char **line, char **key, enum key_operation *operation, char
                linepos++;
 
        /* get the key */
+       if (linepos[0] == '\0')
+               return -1;
        *key = linepos;
+
        while (1) {
                linepos++;
                if (linepos[0] == '\0')
@@ -123,6 +123,8 @@ static int get_key(char **line, char **key, enum key_operation *operation, char
        /* skip whitespace after key */
        while (isspace(linepos[0]))
                linepos++;
+       if (linepos[0] == '\0')
+               return -1;
 
        /* get operation type */
        if (linepos[0] == '=' && linepos[1] == '=') {
@@ -155,6 +157,8 @@ static int get_key(char **line, char **key, enum key_operation *operation, char
        /* skip whitespace after operator */
        while (isspace(linepos[0]))
                linepos++;
+       if (linepos[0] == '\0')
+               return -1;
 
        /* get the value*/
        if (linepos[0] == '"')
@@ -637,6 +641,7 @@ int udev_rules_init(struct udev_rules *rules, int resolve_names)
                list_for_each_entry_safe(name_loop, name_tmp, &name_list, node) {
                        parse_file(rules, name_loop->name);
                        list_del(&name_loop->node);
+                       free(name_loop);
                }
        }