mount: fix unbounded write

Replace sprintf() with snprintf() and specify maximum length of
characters to avoid potential overflow.

Reported-by: GitHub CodeQL (https://codeql.github.com/)
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
Radostin Stoyanov 2024-05-23 17:17:03 +01:00 committed by Andrei Vagin
parent 708f872a6d
commit 30aa8dbe4d

View file

@ -98,7 +98,7 @@ static char *ext_mount_lookup(char *key)
int len = strlen(key);
char mkey[len + 6];
sprintf(mkey, "mnt[%s]", key);
snprintf(mkey, sizeof(mkey), "mnt[%s]", key);
v = external_lookup_by_key(mkey);
if (IS_ERR(v))
v = NULL;