Fix FIONREAD related issues

* Network stack socket module: socket_control(): The FIONREAD argument
  is int, not ssize_t.
* Net kit: getsockopt(): R5_SO_FIONREAD: Fix ioctl() argument. Was
  taking a pointer of what already was a pointer to the buffer.
* libedit: el_gets(): The FIONREAD argument is int, not long.
This commit is contained in:
Ingo Weinhold
2013-11-25 16:07:59 +01:00
parent 9394e66cbc
commit ed9f4719f7
3 changed files with 9 additions and 7 deletions
@@ -550,17 +550,18 @@ socket_control(net_socket* socket, int32 op, void* data, size_t length)
if (data == NULL)
return B_BAD_VALUE;
ssize_t available = socket_read_avail(socket);
if (available < B_OK)
int available = (int)socket_read_avail(socket);
if (available < 0)
return available;
if (is_syscall()) {
if (!IS_USER_ADDRESS(data)
|| user_memcpy(data, &available, sizeof(ssize_t)) != B_OK) {
|| user_memcpy(data, &available, sizeof(available))
!= B_OK) {
return B_BAD_ADDRESS;
}
} else
*(ssize_t *)data = available;
*(int*)data = available;
return B_OK;
}
+3 -2
View File
@@ -315,9 +315,10 @@ getsockopt(int socket, int level, int option, void *value, socklen_t *_length)
{
if (check_r5_compatibility()) {
if (option == R5_SO_FIONREAD) {
// there is no SO_FIONREAD in our stack; we're using FIONREAD instead
// there is no SO_FIONREAD in our stack; we're using FIONREAD
// instead
*_length = sizeof(int);
return ioctl(socket, FIONREAD, &value);
return ioctl(socket, FIONREAD, value);
}
convert_from_r5_sockopt(level, option);
+1 -1
View File
@@ -419,7 +419,7 @@ el_gets(EditLine *el, int *nread)
#ifdef FIONREAD
if (el->el_tty.t_mode == EX_IO && ma->level < 0) {
long chrs = 0;
int chrs = 0;
(void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs);
if (chrs == 0) {