(enet_read): add and use
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8931 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -46,28 +46,37 @@ 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;
|
||||
int ret;
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user