From 24eb4a30982ed18d4716bd59c454a72f161d5982 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 7 Apr 2015 13:11:18 +0200 Subject: device: fix sysattr newline cutter Right now, we always drop the last character of all values we write to sysfs. Fix this! --- src/libsystemd/sd-device/sd-device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 0dd0e14eef..b828fa830a 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -1781,8 +1781,8 @@ _public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, value_len = strlen(_value); /* drop trailing newlines */ - while (value_len > 0 && _value[--value_len] == '\n') - _value[value_len] = '\0'; + while (value_len > 0 && _value[value_len - 1] == '\n') + _value[--value_len] = '\0'; /* value length is limited to 4k */ if (value_len > 4096) -- cgit v1.2.3-54-g00ecf