diff --git a/mongoose.c b/mongoose.c
index 1e46af3674b0f2212bf1235d9dce8299b6edd0b0..e8bbe5354d8a642fa8be6de65d80274146cc1a88 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -3556,7 +3556,7 @@ static void handle_put(struct connection *conn, const char *path) {
 
 static void forward_put_data(struct connection *conn) {
   struct iobuf *io = &conn->ns_conn->recv_iobuf;
-  size_t k = conn->cl < (int64_t) io->len ? conn->cl : io->len;   // To write
+  size_t k = conn->cl < (int64_t) io->len ? conn->cl : (int64_t) io->len;   // To write
   int n = write(conn->endpoint.fd, io->buf, k);   // Write them!
   if (n > 0) {
     iobuf_remove(io, n);