summaryrefslogtreecommitdiff
path: root/src/libelogind
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-04-05 12:17:29 +0200
committerSven Eden <yamakuzure@gmx.net>2017-03-14 07:50:10 +0100
commitead0b80f56cd4d4f0a9e654b271a8957251c0c35 (patch)
tree3f8f2f6c8c3e7959301c8016158deaa09f2f1fea /src/libelogind
parent2c2ecbebd3913607d833617230dc904a05ce0999 (diff)
sd-device: don't use alloca() within loops
I shall not use alloca() within loops I shall not use alloca() within loops I shall not use alloca() within loops I shall not use alloca() within loops ...
Diffstat (limited to 'src/libelogind')
-rw-r--r--src/libelogind/sd-device/device-private.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libelogind/sd-device/device-private.c b/src/libelogind/sd-device/device-private.c
index 86d760cdd..9788df769 100644
--- a/src/libelogind/sd-device/device-private.c
+++ b/src/libelogind/sd-device/device-private.c
@@ -423,9 +423,10 @@ static int device_amend(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_amend(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)