All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-upf@vger.kernel.org, linux-kernel@vger.kernel.org,
	Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>
Subject: [PATCH] udf: use strscpy() instead of strcpy() for regid ident field
Date: Sat, 27 Jun 2026 18:19:48 +0000	[thread overview]
Message-ID: <20260627181948.2118-1-mahad.ibrahim.dev@gmail.com> (raw)

strcpy() is deprecated as it performs no bounds checking. Replace the
three call sites that copy UDF_ID_DEVELOPER into the regid ident field
with strscpy().

The current string fits the field with room to spare, so there is no
overflow today. strscpy() bounds the copy to the destination and
NUL-terminates, keeping it safe if the string or the field size
changes later.

Signed-off-by: Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>
---
 fs/udf/inode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 67bcf83758c8..3140e001b315 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1809,7 +1809,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
 		}
 		eid = (struct regid *)dsea->impUse;
 		memset(eid, 0, sizeof(*eid));
-		strcpy(eid->ident, UDF_ID_DEVELOPER);
+		strscpy(eid->ident, UDF_ID_DEVELOPER, sizeof(eid->ident));
 		eid->identSuffix[0] = UDF_OS_CLASS_UNIX;
 		eid->identSuffix[1] = UDF_OS_ID_LINUX;
 		dsea->majorDeviceIdent = cpu_to_le32(imajor(inode));
@@ -1833,7 +1833,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
 		udf_time_to_disk_stamp(&fe->modificationTime, inode_get_mtime(inode));
 		udf_time_to_disk_stamp(&fe->attrTime, inode_get_ctime(inode));
 		memset(&(fe->impIdent), 0, sizeof(struct regid));
-		strcpy(fe->impIdent.ident, UDF_ID_DEVELOPER);
+		strscpy(fe->impIdent.ident, UDF_ID_DEVELOPER, sizeof(fe->impIdent.ident));
 		fe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
 		fe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
 		fe->uniqueID = cpu_to_le64(iinfo->i_unique);
@@ -1872,7 +1872,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
 		udf_time_to_disk_stamp(&efe->attrTime, inode_get_ctime(inode));
 
 		memset(&(efe->impIdent), 0, sizeof(efe->impIdent));
-		strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER);
+		strscpy(efe->impIdent.ident, UDF_ID_DEVELOPER, sizeof(efe->impIdent.ident));
 		efe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
 		efe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
 		efe->uniqueID = cpu_to_le64(iinfo->i_unique);
-- 
2.54.0


             reply	other threads:[~2026-06-27 18:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-27 18:19 Mahad Ibrahim [this message]
2026-06-27 21:26 ` [PATCH] udf: use strscpy() instead of strcpy() for regid ident field David Laight
2026-06-28 11:11   ` Mahad Ibrahim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260627181948.2118-1-mahad.ibrahim.dev@gmail.com \
    --to=mahad.ibrahim.dev@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-upf@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.