summaryrefslogtreecommitdiff
path: root/sanei/sanei_tcp.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-05-26 12:15:18 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-05-26 12:15:18 +0200
commitc393b9b94c4718c86df08b26ec36a4a2ba4c34ad (patch)
treec085558d171157c60138c85a02a9d43e92d4b4e4 /sanei/sanei_tcp.c
parent55a1f6d3b8dcb0493a112602ea277a706554efcd (diff)
parentd2c6277fad9d31cde9499c4a34c0bb3e30efa509 (diff)
Merge branch 'release/experimental/1.0.30-1_experimental1'experimental/1.0.30-1_experimental1
Diffstat (limited to 'sanei/sanei_tcp.c')
-rw-r--r--sanei/sanei_tcp.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/sanei/sanei_tcp.c b/sanei/sanei_tcp.c
index 87a73d1..d6f8efe 100644
--- a/sanei/sanei_tcp.c
+++ b/sanei/sanei_tcp.c
@@ -45,6 +45,11 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
+
+#ifndef SSIZE_MAX
+#define SSIZE_MAX LONG_MAX
+#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
@@ -115,15 +120,21 @@ sanei_tcp_close(int fd)
}
ssize_t
-sanei_tcp_write(int fd, const u_char * buf, int count)
+sanei_tcp_write(int fd, const u_char * buf, size_t count)
{
return send(fd, buf, count, 0);
}
ssize_t
-sanei_tcp_read(int fd, u_char * buf, int count)
+sanei_tcp_read(int fd, u_char * buf, size_t count)
{
- ssize_t bytes_recv = 0, rc = 1;
+ size_t bytes_recv = 0;
+ ssize_t rc = 1;
+
+ if (count > SSIZE_MAX) {
+ errno = EINVAL;
+ return -1;
+ }
while (bytes_recv < count && rc > 0)
{