diff options
author | Theodore Ts'o <tytso@mit.edu> | 2024-05-01 17:22:55 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2024-05-01 17:22:55 -0400 |
commit | d04a708ecf955610654a2015de8657642857912d (patch) | |
tree | 9e4d754ac57b795daeaf09448adbc365097dd981 | |
parent | 1b9e68e0ff22933d1bab5defa761268e904daf28 (diff) | |
download | e2fsprogs-d04a708ecf955610654a2015de8657642857912d.tar.gz |
e4defrag: use snprintf to assure that there can't be a buffer overflow
The size of msg_buffer is carefully calculated so it can never
overflow, but it triggers a Coverity warning. Use snprintf instead of
sprintf to silence the Coverity warning.
Addresses-Coverty-Bug: 1520603
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | misc/e4defrag.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/misc/e4defrag.c b/misc/e4defrag.c index e3011d7cd..5bfa6ff14 100644 --- a/misc/e4defrag.c +++ b/misc/e4defrag.c @@ -1206,9 +1206,8 @@ static int file_statistic(const char *file, const struct stat64 *buf, if (mode_flag & DETAIL) { /* Print statistic info */ - sprintf(msg_buffer, "[%u/%u]%.*s", - defraged_file_count, total_count, - PATH_MAX, file); + snprintf(msg_buffer, sizeof(msg_buffer), "[%u/%u]%.*s", + defraged_file_count, total_count, PATH_MAX, file); if (current_uid == ROOT_UID) { if (strlen(msg_buffer) > 40) printf("\033[79;0H\033[K%s\n" |