diff --git a/src/trees-ostream.c b/src/trees-ostream.c
index c2b3a66681c4d2ed33150e4d7656000255345523..1b25a91f574f1dadb59b3e1aa6034168bb75542c 100644
--- a/src/trees-ostream.c
+++ b/src/trees-ostream.c
@@ -87,7 +87,7 @@ trees_ostream_send_chunk(struct trees_ostream *sstream,
   unsigned char ciphertext[ciphertext_len];
 
   /* Extra protection here against overflow. */
-  if (chunk_size < (SSIZE_MAX - crypto_box_SEALBYTES)) {
+  if (chunk_size >= (SSIZE_MAX - crypto_box_SEALBYTES)) {
     sstream->ostream.ostream.stream_errno = EIO;
     goto err;
   }