summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libsystemd/sd-device/sd-device.c4
1 files changed, 2 insertions, 2 deletions
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)