summaryrefslogtreecommitdiffstats
path: root/crypto/heimdal/appl/test/gss_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/heimdal/appl/test/gss_common.c')
-rw-r--r--crypto/heimdal/appl/test/gss_common.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/crypto/heimdal/appl/test/gss_common.c b/crypto/heimdal/appl/test/gss_common.c
index 821114b..4b5319a 100644
--- a/crypto/heimdal/appl/test/gss_common.c
+++ b/crypto/heimdal/appl/test/gss_common.c
@@ -34,7 +34,7 @@
#include "test_locl.h"
#include <gssapi.h>
#include "gss_common.h"
-RCSID("$Id: gss_common.c,v 1.7 2000/02/12 21:31:38 assar Exp $");
+RCSID("$Id: gss_common.c,v 1.9 2000/11/15 23:05:27 assar Exp $");
void
write_token (int sock, gss_buffer_t buf)
@@ -46,28 +46,36 @@ write_token (int sock, gss_buffer_t buf)
net_len = htonl(len);
- if (write (sock, &net_len, 4) != 4)
+ if (net_write (sock, &net_len, 4) != 4)
err (1, "write");
- if (write (sock, buf->value, len) != len)
+ if (net_write (sock, buf->value, len) != len)
err (1, "write");
gss_release_buffer (&min_stat, buf);
}
+static void
+enet_read(int fd, void *buf, size_t len)
+{
+ ssize_t ret;
+
+ ret = net_read (fd, buf, len);
+ if (ret == 0)
+ errx (1, "EOF in read");
+ else if (ret < 0)
+ errx (1, "read");
+}
+
void
read_token (int sock, gss_buffer_t buf)
{
u_int32_t len, net_len;
- if (read(sock, &net_len, 4) != 4)
- err (1, "read");
+ enet_read (sock, &net_len, 4);
len = ntohl(net_len);
buf->length = len;
- buf->value = malloc(len);
- if (buf->value == NULL)
- err (1, "malloc %u", len);
- if (read (sock, buf->value, len) != len)
- err (1, "read");
+ buf->value = emalloc(len);
+ enet_read (sock, buf->value, len);
}
void
OpenPOWER on IntegriCloud