diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-10-17 21:23:52 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-10-17 21:25:42 +0200 |
commit | 4fa25d62bd586b56fa6a30009f41ce6dbc5fdd54 (patch) | |
tree | 6ee959fd934aebbb08f2077709dbb5f33f927c71 /src/journal/journal-vacuum.c | |
parent | dbc4fbae58e39cb0d33738f0a4d1e74511ed1fb5 (diff) |
journal: fix potential integer overflow
Diffstat (limited to 'src/journal/journal-vacuum.c')
-rw-r--r-- | src/journal/journal-vacuum.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c index 22c9cfcd52..731f6c770f 100644 --- a/src/journal/journal-vacuum.c +++ b/src/journal/journal-vacuum.c @@ -243,6 +243,7 @@ int journal_directory_vacuum( have_seqnum = false; } else + /* We do not vacuum active files or unknown files! */ continue; patch_realtime(directory, de->d_name, &st, &realtime); @@ -291,7 +292,12 @@ int journal_directory_vacuum( if (unlinkat(dirfd(d), list[i].filename, 0) >= 0) { log_debug("Deleted archived journal %s/%s.", directory, list[i].filename); - sum -= list[i].usage; + + if ((uint64_t) list[i].usage > sum) + sum -= list[i].usage; + else + sum = 0; + } else if (errno != ENOENT) log_warning("Failed to delete %s/%s: %m", directory, list[i].filename); } |