From cd0ff307889e171778dbe1ad9572a73d2cd09340 Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Wed, 14 Oct 2026 10:07:40 +0000 Subject: [PATCH] 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 --- isobusfs/isobusfs_srv_fa.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/isobusfs/isobusfs_srv_fa.c b/isobusfs/isobusfs_srv_fa.c index 4551270..06c50a0 100644 --- a/isobusfs/isobusfs_srv_fa.c +++ b/isobusfs/isobusfs_srv_fa.c @@ -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;