mirror of https://github.com/openzfs/zfs.git
Fix off-by-1 truncation of hw_serial when converting from integer to string, when writing to /proc/sys/kernel/spl/spl_hostid.
Fixes hostid mismatch which leads to assertion failure when the hostid/hw_serial is a 10-character decimal number: $ zpool status pool: lustre state: ONLINE lt-zpool: zpool_main.c:3176: status_callback: Assertion `reason == ZPOOL_STATUS_OK' failed. zsh: 5262 abort zpool status
This commit is contained in:
parent
6c33eb8162
commit
a0b5ae8aca
|
@ -472,8 +472,9 @@ proc_dohostid(struct ctl_table *table, int write, struct file *filp,
|
|||
RETURN(-EINVAL);
|
||||
|
||||
spl_hostid = (long) val;
|
||||
(void)snprintf(hw_serial, HW_HOSTID_LEN-1, "%u",
|
||||
(void) snprintf(hw_serial, HW_HOSTID_LEN, "%u",
|
||||
(val >= 0) ? val : -val);
|
||||
hw_serial[HW_HOSTID_LEN - 1] = '\0';
|
||||
*ppos += *lenp;
|
||||
} else {
|
||||
len = snprintf(str, sizeof(str), "%lx", spl_hostid);
|
||||
|
|
Loading…
Reference in New Issue