]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
logging: handle too many file logs
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 24 Jun 2020 09:27:41 +0000 (11:27 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 25 Jun 2020 10:43:25 +0000 (12:43 +0200)
Don't rely on an assert to catch insufficient maximum number of file
logs (e.g. after introducing a new file log).

logging.c

index d5440a183af9b01f0c39fa9a44731f52c051ebd6..57f69453c143464fd2f92330f0107ecb8555c363 100644 (file)
--- a/logging.c
+++ b/logging.c
@@ -243,7 +243,10 @@ LOG_CloseParentFd()
 LOG_FileID
 LOG_FileOpen(const char *name, const char *banner)
 {
-  assert(n_filelogs < MAX_FILELOGS);
+  if (n_filelogs >= MAX_FILELOGS) {
+    assert(0);
+    return -1;
+  }
 
   logfiles[n_filelogs].name = name;
   logfiles[n_filelogs].banner = banner;