roken: Do not use net_read() for regular files!
The bug fixed herein almost certainly means that PKINIT was never working on Windows, since lib/hx509 uses rk_undumpdata() to read regular files containing certificates and keys, but then since rk_undumpdata() was using net_read(), that can't have worked. On Windows net_read() insists on the FD being a socket, and because of winsock, the namespaces of socket and file descriptors on Windows are distinct.
This commit is contained in:
@@ -71,6 +71,9 @@ rk_undumpdata(const char *filename, void **buf, size_t *size)
|
||||
ret = errno;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (sb.st_size < 0)
|
||||
sb.st_size = 0;
|
||||
*buf = malloc(sb.st_size);
|
||||
if (*buf == NULL) {
|
||||
ret = ENOMEM;
|
||||
@@ -78,7 +81,7 @@ rk_undumpdata(const char *filename, void **buf, size_t *size)
|
||||
}
|
||||
*size = sb.st_size;
|
||||
|
||||
sret = net_read(fd, *buf, *size);
|
||||
sret = read(fd, *buf, *size);
|
||||
if (sret < 0)
|
||||
ret = errno;
|
||||
else if (sret != (ssize_t)*size)
|
||||
|
Reference in New Issue
Block a user