]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
rewrite assertions with very long messages
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 14 Mar 2016 14:15:51 +0000 (15:15 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 14 Mar 2016 14:15:51 +0000 (15:15 +0100)
cmdmon.c
sched.c

index adaef8eff6c3e2283449bfea33652c321032acef..ade1334c4b6a5f702d08152122a8258cc4fb8cc2 100644 (file)
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -266,9 +266,10 @@ CAM_Initialise(int family)
     r.command = htons(i);
     command_length = PKL_CommandLength(&r);
     padding_length = PKL_CommandPaddingLength(&r);
-    assert(padding_length <= MAX_PADDING_LENGTH && padding_length <= command_length);
-    assert((command_length >= offsetof(CMD_Request, data) &&
-            command_length <= sizeof (CMD_Request)) || command_length == 0);
+    if (padding_length > MAX_PADDING_LENGTH || padding_length > command_length ||
+        command_length > sizeof (CMD_Request) ||
+        (command_length && command_length < offsetof(CMD_Request, data)))
+      assert(0);
   }
 
   for (i = 1; i < N_REPLY_TYPES; i++) {
@@ -279,8 +280,9 @@ CAM_Initialise(int family)
     r.status = STT_SUCCESS;
     r.data.manual_list.n_samples = htonl(MAX_MANUAL_LIST_SAMPLES);
     reply_length = PKL_ReplyLength(&r);
-    assert((reply_length >= offsetof(CMD_Reply, data) &&
-            reply_length <= sizeof (CMD_Reply)) || reply_length == 0);
+    if ((reply_length && reply_length < offsetof(CMD_Reply, data)) ||
+        reply_length > sizeof (CMD_Reply))
+      assert(0);
   }
 
   sock_fdu = -1;
diff --git a/sched.c b/sched.c
index 78016de9d49019fcfd5e82e7ba21eaeffe1df940..6083c97a447baae0fa9418f7c2ca3882d5afe4ac 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -179,7 +179,8 @@ SCH_AddInputFileHandler
   /* Don't want to allow the same fd to register a handler more than
      once without deleting a previous association - this suggests
      a bug somewhere else in the program. */
-  assert(!FD_ISSET(fd, &read_fds));
+  if (FD_ISSET(fd, &read_fds))
+    assert(0);
 
   ++n_read_fds;
   
@@ -208,7 +209,8 @@ SCH_RemoveInputFileHandler(int fd)
   assert(initialised);
 
   /* Check that a handler was registered for the fd in question */
-  assert(FD_ISSET(fd, &read_fds));
+  if (!FD_ISSET(fd, &read_fds))
+    assert(0);
 
   --n_read_fds;