Skip to content

Commit

Permalink
mount: fix unbounded write
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rst0git authored and avagin committed May 24, 2024
1 parent 516b369 commit 0f3246a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion criu/mount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0f3246a

Please sign in to comment.