]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: Allocate enough room for tags string 2976/head
authorMartin Pitt <martin.pitt@ubuntu.com>
Wed, 6 Apr 2016 21:50:39 +0000 (23:50 +0200)
committerMartin Pitt <martin.pitt@ubuntu.com>
Wed, 6 Apr 2016 21:50:39 +0000 (23:50 +0200)
Fix commit 1d88a2: We need to allocate another byte for building the "tags"
string, as we append an extra ':' and still need the NUL terminator.

src/libsystemd/sd-device/sd-device.c

index e9f8970d2ca04b0de168c16e5a3a8c720ce2d226..e787cb69d34b1d1a5d5c315ff68a9be8039b9a9e 100644 (file)
@@ -1492,7 +1492,7 @@ static int device_properties_prepare(sd_device *device) {
                 for (tag = sd_device_get_tag_first(device); tag; tag = sd_device_get_tag_next(device)) {
                         char *e;
 
-                        if (!GREEDY_REALLOC(tags, tags_allocated, tags_len + strlen(tag) + 1))
+                        if (!GREEDY_REALLOC(tags, tags_allocated, tags_len + strlen(tag) + 2))
                                 return -ENOMEM;
                         e = stpcpy(stpcpy(tags + tags_len, tag), ":");
                         tags_len = e - tags;