(unix_bytes): read until the other side give us all or fail.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18794 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -87,7 +87,7 @@ unix_seed(const void *indata, int size)
|
|||||||
static int
|
static int
|
||||||
unix_bytes(unsigned char *outdata, int size)
|
unix_bytes(unsigned char *outdata, int size)
|
||||||
{
|
{
|
||||||
ssize_t ret;
|
ssize_t count;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (size <= 0)
|
if (size <= 0)
|
||||||
@@ -97,10 +97,18 @@ unix_bytes(unsigned char *outdata, int size)
|
|||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = read(fd, outdata, size);
|
while (size > 0) {
|
||||||
|
count = read (fd, outdata, size);
|
||||||
|
if (count < 0 && errno == EINTR)
|
||||||
|
continue;
|
||||||
|
else if (count <= 0) {
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
outdata += count;
|
||||||
|
size -= count;
|
||||||
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
if (size != ret)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user