summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/util_sock.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/source4/lib/util_sock.c b/source4/lib/util_sock.c
index 95e0c5fe0c..57d3715cfc 100644
--- a/source4/lib/util_sock.c
+++ b/source4/lib/util_sock.c
@@ -187,6 +187,11 @@ ssize_t read_data(int fd, char *buffer, size_t N)
ssize_t ret;
size_t total=0;
+ if (fd == -1) {
+ errno = EIO;
+ return -1;
+ }
+
while (total < N) {
ret = sys_read(fd,buffer + total,N - total);
if (ret == 0) {
@@ -209,6 +214,11 @@ ssize_t write_data(int fd, const char *buffer, size_t N)
size_t total=0;
ssize_t ret;
+ if (fd == -1) {
+ errno = EIO;
+ return -1;
+ }
+
while (total < N) {
ret = sys_write(fd, buffer + total, N - total);
if (ret == -1) {