chiark / gitweb /
063 release
[elogind.git] / udev_rules_parse.c
index 0259268c8faa36b0ce8e7327c844798d4d7c12e0..be0757374e216f2e2822e75c955c83a49a7b138f 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.
@@ -241,6 +238,7 @@ static int add_to_rules(struct udev_rules *rules, char *line)
        int valid;
        char *linepos;
        char *attr;
+       size_t padding;
        int retval;
 
        /* get all the keys */
@@ -506,6 +504,11 @@ static int add_to_rules(struct udev_rules *rules, char *line)
 
        /* grow buffer and add rule */
        rule_size = sizeof(struct udev_rule) + rule->bufsize;
+       padding = (sizeof(size_t) - rule_size % sizeof(size_t)) % sizeof(size_t);
+       dbg("add %zi padding bytes", padding);
+       rule_size += padding;
+       rule->bufsize += padding;
+
        rules->buf = realloc(rules->buf, rules->bufsize + rule_size);
        if (!rules->buf) {
                err("realloc failed");