X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Flibelogind%2Fsd-device%2Fdevice-private.c;h=9788df769cfbf249e730da89838a26092974523b;hb=a04d70ee829285fff6d55e90ad155537daaad431;hp=544b837b12f6c378c13dbabc86c70c5559dab4ce;hpb=ccae5a25c961d456a0b42da4bd8b0f8d39c530d9;p=elogind.git diff --git a/src/libelogind/sd-device/device-private.c b/src/libelogind/sd-device/device-private.c index 544b837b1..9788df769 100644 --- a/src/libelogind/sd-device/device-private.c +++ b/src/libelogind/sd-device/device-private.c @@ -366,7 +366,7 @@ static int device_set_devgid(sd_device *device, const char *gid) { return 0; } -static int device_ammend(sd_device *device, const char *key, const char *value) { +static int device_amend(sd_device *device, const char *key, const char *value) { int r; assert(device); @@ -423,9 +423,10 @@ static int device_ammend(sd_device *device, const char *key, const char *value) size_t l; FOREACH_WORD(word, l, value, state) { - char *devlink; + char devlink[l + 1]; - devlink = strndupa(word, l); + strncpy(devlink, word, l); + devlink[l] = '\0'; r = device_add_devlink(device, devlink); if (r < 0) @@ -436,9 +437,10 @@ static int device_ammend(sd_device *device, const char *key, const char *value) size_t l; FOREACH_WORD_SEPARATOR(word, l, value, ":", state) { - char *tag; + char tag[l + 1]; - tag = strndupa(word, l); + (void)strncpy(tag, word, l); + tag[l] = '\0'; r = device_add_tag(device, tag); if (r < 0) @@ -507,7 +509,7 @@ static int device_append(sd_device *device, char *key, const char **_major, cons return -EINVAL; } - r = device_ammend(device, key, value); + r = device_amend(device, key, value); if (r < 0) return r; }