mirror of
https://github.com/linux-can/can-utils.git
synced 2026-11-04 07:21:13 +01:00
isobusfs: srv: check strdup() result when adding a new handle
The path of a handle is also used to mark the handle slot as used. When strdup() failed the handle was returned to the client but the slot was still marked as free and got reused (and the file descriptor of the first user got lost) with the next open request. Return -ENOMEM when the path can not be allocated. The callers close the file descriptor and the handle slot remains unused. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
This commit is contained in:
@@ -45,6 +45,9 @@ static int isobusfs_srv_add_file(struct isobusfs_srv_priv *priv,
|
||||
}
|
||||
|
||||
priv->handles[j].path = strdup(path);
|
||||
if (!priv->handles[j].path)
|
||||
return -ENOMEM;
|
||||
|
||||
priv->handles[j].fd = fd;
|
||||
priv->handles[j].dir = dir;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user