lvmlockd: allow 1 more extra character
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 27 Jun 2025 09:15:05 +0000 (11:15 +0200)
committerMarian Csontos <mcsontos@redhat.com>
Mon, 29 Sep 2025 16:07:44 +0000 (18:07 +0200)
Function dm_strncpy() ensures the last character is \0,
so pass whole array size for buffer size.

This give 1 extra character for use to store owner state and name.

(cherry picked from commit 879fb36f0a6c4fda783efbc02b4bf6477f18a4af)

daemons/lvmlockd/lvmlockd-sanlock.c

index 89df4ec44fe0578175c7bc6a633d8b40bbad80c1..6ef59b591bf97d42aec1f3fb1dbe1d56c36c16b8 100644 (file)
@@ -2208,10 +2208,10 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
                        owner->timestamp = (uint32_t)owner_host.timestamp;
 
                        if ((host_state = _host_flags_to_str(owner_host.flags)))
-                               dm_strncpy(owner->state, host_state, OWNER_STATE_SIZE-1);
+                               dm_strncpy(owner->state, host_state, sizeof(owner->state));
 
                        if (owner_name) {
-                               dm_strncpy(owner->name, owner_name, OWNER_NAME_SIZE-1);
+                               dm_strncpy(owner->name, owner_name, sizeof(owner->name));
                                free(owner_name);
                        }
 
@@ -2553,7 +2553,7 @@ int lm_vg_status_sanlock(struct lockspace *ls, struct action *act)
        act->owner.timestamp = (uint32_t)hs->timestamp;
 
        if ((host_state = _host_flags_to_str(hs->flags)))
-               dm_strncpy(act->owner.state, host_state, OWNER_STATE_SIZE-1);
+               dm_strncpy(act->owner.state, host_state, sizeof(act->owner.state));
 
        free(hs);
        return 0;
This page took 0.091985 seconds and 5 git commands to generate.