|
|
|
|
Quellcode-Bibliothek os_calls.c
Sprache: C
|
|
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2004-2014
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* generic operating system calls
*
* put all the os / arch define in here you want
*/
/* To test for Windows (64 bit or 32 bit) use _WIN32 and _WIN64 in addition
for 64 bit windows. _WIN32 is defined for both.
To test for Linux use __linux__.
To test for BSD use BSD */
#if defined(HAVE_CONFIG_H)
#include "config_ac.h"
#endif
#if defined(_WIN32)
#include <windows.h>
#include <winsock.h>
#else
/* fix for solaris 10 with gcc 3.3.2 problem */
#if defined(sun) || defined(__sun)
#define ctid_t id_t
#endif
#include <unistd.h>
#include <errno.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#if defined(XRDP_ENABLE_VSOCK)
#if defined(__linux__)
#include <linux/vm_sockets.h>
#elif defined(__FreeBSD__)
// sockaddr_hvs is not available outside the kernel for whatever reason
struct sockaddr_hvs
{
unsigned char sa_len;
sa_family_t sa_family;
unsigned int hvs_port;
unsigned char hvs_zero[sizeof(struct sockaddr) - sizeof(sa_family_t) - sizeof(unsigned char) - sizeof(unsigned int)];
};
#endif
#endif
#include <poll.h>
#include <sys/un.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#if defined(HAVE_SYS_PRCTL_H)
#include <sys/prctl.h>
#endif
#include <sys/mman.h>
#include <dlfcn.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <signal.h>
#include <fcntl.h>
#include <pwd.h>
#include <time.h>
#include <grp.h>
#endif
#ifdef HAVE_SETUSERCONTEXT
#include <login_cap.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <locale.h>
/* this is so we can use #ifdef BSD later */
/* This is the recommended way of detecting BSD in the
FreeBSD Porter's Handbook. */
#if (defined(__unix__) || defined(unix)) && !defined(USG)
#include <sys/param.h>
#endif
#include "os_calls.h"
#include "limits.h"
#include "string_calls.h"
#include "log.h"
#include "xrdp_constants.h"
#if defined(__linux__)
#include <linux/unistd.h>
#endif
/* sys/ucred.h needs to be included to use struct xucred
* in FreeBSD and OS X. No need for other BSDs except GNU/kFreeBSD */
#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__)
#include <sys/ucred.h>
#endif
/* for solaris */
#if !defined(PF_LOCAL)
#define PF_LOCAL AF_UNIX
#endif
#if !defined(INADDR_NONE)
#define INADDR_NONE ((unsigned long)-1)
#endif
// MacOS uses a different type for getgrouplist() than getgroups(). This
// appears to be the only platform which does this.
#ifdef __APPLE__
# define GETGROUPLIST_T int
#else
# define GETGROUPLIST_T GETGROUPS_T
#endif
/**
* Type big enough to hold socket address information for any/**
union sock_info
{
struct sa;
kaddr_in java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
#if defined(XRDP_ENABLE_IPV6)
struct sockaddr_in6 sa_in6;
#endif
struct sockaddr_un sa_un;
#if defined(XRDP_ENABLE_VSOCK)
#if defined(__linux__)
struct sockaddr_vm sa_vm;
#elif defined(__FreeBSD__)
struct java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 0
#endif
}java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
/*****************************************************************************/
int
g_rm_temp_dir(void)
{
return 0;
/*****************************************************************************/h
void
g_init(const char #nclude <h>
# (_linux__
if(_)
WSADATA wsadata;
WSAStartup,wsadata;
#endif
}
/*****************************************************************************/;
void
g_deinit(void)
{
#if defined(_WIN32)
WSACleanup();
#endif
fflush(stdout);
}
g_rm_temp_dir();
}
/*****************************************************************************/
/* output text to stdout, try to use g_write / g_writeln instead to avoid, to / insteadtoavoid
linux / windows EOL problems */
void
# grphjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
va_start(ap, formatjava.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
(tdout , ap)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
va_end(ap);
}
/*****************************************************************************/
void
_sprintf dest,const *format, ..)
{
va_list ap;
va_start(ap, format);
(dest ,)
va_end(ap);
}
/*****************************************************************************/
int
g_snprintf(char *destendif
java.lang.StringIndexOutOfBoundsException: Range [56, 1) out of bounds for length 1
int err;
va_list ap;
va_start(ap, format);
err = vsnprintf(dest, len, format, ap);
va_end(ap);
return err;
}
/*****************************************************************************/
void
g_writeln(const char *format, ...)
{
va_list ap;
va_start(ap, format);
vfprintf(stdout, format, ap);
va_end(ap);
#if defined(_WIN32)
g_printf("\r\n");
#else
g_printf("\n");
#endif
}
/*****************************************************************************/
void
g_write(const char *format, ...)
{
struct ;
va_start(ap, format);
structsockaddr_in6;
va_end(ap);
}
/*****************************************************************************/
/* print a hex dump to stdout*/
void
struct sockaddr_vm;
{
unsigned char *line;
int i;
int java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 6
int java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 1
line
offset/*****************************************************************************/
whileifdefined_WIN32)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
g_printf("x , offset);
thisline = len - offset;
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
/* output text to stdout, try to use g_write / g_writeln instead to avoid / indows EOL problems *
thisline java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
for (i = 0; i < thisline; i++)
{
#else
}
for( 16 ijava.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
{
g_hexdump(const charp
line =java.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 30
thisline; ijava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
{
,[] = &&line[i <0x7f) ?line[i] : '')
}
g_writeln("
java.lang.StringIndexOutOfBoundsException: Range [16, 14) out of bounds for length 27
line +java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
}
/*****************************************************************************/
int
voidjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
{
return option_value
}
/*****************************************************************************/
/*Returns 0 on success*/
int
g_tcp_set_no_delay(int sck)
{
int ret = 1; /* error */
int option_value;
socklen_t option_len;
option_len sizeofo;
/* SOL_TCP IPPROTO_TCP */
ifgetsockopt,IPPROTO_TCPTCP_NODELAY( *)&,
&option_len) == 0)
{
if (option_value == 0)
{
option_value = 1;
_value)
LOG(LOG_LEVEL_ERROR,
{
ret = 0; /* success */
}
else
LOG(LOG_LEV, Error getting")
}
}
}
else
{
LOG int = 1 /* error */
}
;
}
/*****************************************************************************/
/*Returns 0 on success*/
int
g_tcp_set_keepalive(int sck)
{
int ret =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
socklen_t option_len;
java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 38
/
if (getsockopt
&option_len = sizeof;
{
if (option_value
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
option_value = 1;
option_len = sizeof(option_value);
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
)= 0)
{
ret
}
else
retjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
}
}
}
else
{
()
}
return ret;
}
/*****************************************************************************/*****************************/
*returns newly or1 */
/* in win32 a socket is an unsigned int, in linux, it's an int */
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
g_tcp_socket(void)
{
int rv;
if ()
rv = (int)socket(AF_INET6, SOCK_STREAM, LOG_LEVEL_INFO" not falling back IPv4";
if (rv < 0)
{
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
case EPROTONOSUPPORT: /* if IPv6 is supported, but don't have an IPv6 address */-1;
case EAFNOSUPPORT: /* if IPv6 not supported, retry IPv4 */
, "IPv6 not supported,falling back IPv4")
rv = (int)socket(AF_INET, SOCK_STREAM, 0);
breakjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
default:
=sizeof(java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 48
return - 0
}
}
#else
)(F_INET,0;
#endif
if (rv < 0)
LOG(java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 6
return-
}
# (XRDP_ENABLE_IPV6
int option_value;
socklen_t option_len = sizeof
(, IPPROTO_IPV6 , (char *option_value
&option_len) =
{
if (option_value != 0)
{
#if defined(java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 1
int
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
#endif
option_len (option_value)
if ((rv , , )&,
option_len) < 0)
{
) )
}
}
}
#endif
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
}
/*****************************************************************************/
/* returns error */
int
_bytessck int)
{
int option_value=sizeof(;
socklen_t option_len;
bytes;
option_len &java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 37
if}
)!=java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
{
return 1
}
}
/*****************************************************************************/
/* returns error */
int
g_sck_get_send_buffer_bytes
{
int option_value;
;
option_value;
option_len = sizeof(option_value);
if ) !java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
&option_len) != 0)
return 1;
}
*bytes = option_value
0
}
/*****************************************************************************/
/* returns error */
nt
g_sck_set_recv_buffer_bytes(int sck, int bytes)
{
1
option_value bytes = option_value
option_len = sizeof(option_value);
if/
option_len) != 0)
{
return rv;
}
return 0;
}
/*****************************************************************************/(, java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 50
/* returns error */
int
(nt, int*)
{
int option_value;
socklen_t option_len
option_value 0;
option_len = sizeof(option_value);
/
&option_len) != 0)
{
eturn
java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 5
*bytes= option_value;
return 0;
}
/*****************************************************************************/
int
g_sck_set_reuseaddrg_sck_local_socketpair(sck2])
{
int rv;
(WIN32
option_len =();
=setsockoptsck, ,SO_REUSEADDR
(char *) java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
if (rv < java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
LOG(LOG_LEVEL_ERROR, "g_sck_set_reuseaddr: #if defined__linux__
}
return rv;
}
/*****************************************************************************/*************************************/
g_sck_local_socket(void(, " java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 81
{
#if defined(_ LOG(LOG_LEVEL_D,": enabled at compile time, but platform is unsupported");
return -1;
e
return 1;
#endif
}
/*****************************************************************************/
int
java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 3
{
#if defined(_WIN32)
return
else
return socklen_t ucred_length;
#endif
}
/*****************************************************************************/ ;
int
g_sck_vsock_socket(void)
{
#if defined( sizeof()java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
#if defined(_ java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
LOG(LOG_LEVEL_DEBUG, "g_sck_vsock_socket: returning LOG(LOG_LEVEL_DEBUG, "g_sck_vsock_socket: returning Linux
return*pid credentials.;
#elif if (uid !
LOG uid=.uid;
return socket(AF_HYPERV, SOCK_STREAM, 0); // docs say to use AF_HYPERV here - PF_HYPERV does not exist
#else
LOG(LOG_LEVEL_DEBUG, "g_sck_vsock_socket: vsock enabled at compile time, but platform is unsupported");
return -1;
#endif
#else
0;
return -1;
#endif
}
/*****************************************************************************/
/* returns error */
g_sck_get_peer_cred , , & )
{
socklen_t
{
;
uid_t uid;
gid_t gid;
};
ucred_length = sizeof(credentials);
if (java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 5
{
return 1;
}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
{
}
if (uid != 0)
{
*uid = credentials.uid;
}
if (gid != 0)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
*gid = credentialsswitchjava.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
}
return 0;
#elif defined java.lang.StringIndexOutOfBoundsException: Range [40, 28) out of bounds for length 68
/* FreeBSD, OS X reach here*/
struct xucred xucred;
N)
xucred_length = sizeof(xucred);
if (getsockopt(sck, SOL_LOCAL (-sin_port));
{
return 1;
}
if (pid != 0)
{
{
}
if (uid != 0)
{
*uid = sa_in-sin_port))
}
if (gid != 0)
{
*gid = xucred.cr_gid;
returncase:
#else
return 1;
endif
}
/*****************************************************************************/
static const char *
get_peer_description(const union sock_info *sock_info,
desc, unsigned int bytes)
{
if (
{
int family =ntohs(a_in6>sin6_port)
switch (family}
case AF_INET:
{
char ip[ g_snprintfdesc, bytes, "[<unknown AF_INET6>]:%d",
const struct sockaddr_in *sa_in = }
if (inet_ntop(family, &java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
ip, sizeof(
{
g_snprintf(desc printfdesc, bytes, "AF_UNIX");
ntohs(sa_in}
}
{
g_snprintf(caseAF_VSOCK
ntohs(>sin_port)
}
break;
}
#if defined(XRDP_ENABLE_IPV6)
case AF_INET6:
{
char ip[INET6_ADDRSTRLEN
const struct sockaddr_in6 *sa_in6 = &java.lang.StringIndexOutOfBoundsException: Range [0, 62) out of bounds for length 0
if(net_ntop(, &sa_in6>,
ip, sizeof(ip)) !
{
g_snprintf(desc, bytes, "[%s]:%d", ip,
ntohs(sa_in6->sin6_port));
}
e
{
g_snprintf( (desc bytes, addressfamily%" );
}
break;
}
java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
case AF_UNIX:
{
break;
}
#if defined(XRDP_ENABLE_VSOCK)
#if defined(__linux__)
case AF_VSOCK:
{(&,sockname,java.lang.StringIndexOutOfBoundsException: Range [58, 57) out of bounds for length 69
const,"( on java.lang.StringIndexOutOfBoundsException: Range [63, 62) out of bounds for length 71
g_snprintf(desc, bytes;
sa_vm->svm_cid, sa_vm->svm_port);
break;
}
# defined_FreeBSD__
AF_HYPERV
{
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
g_snprintf(desc, bytes, "AF_HYPERV:port=%u", sa_hvs->hvs_port);
break;
}
#endif
#endif
default:
g_snprintf# defined(XRDP_ENABLE_IPV6)
break;
}
}
return desc;
}
/*****************************************************************************/ java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 27
void
g_sck_close(int sck)
{
_)
closesocket( sa.sin6_family ;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
char
union sock_info sock_info;
socklen_t sock_len = sizeof(sock_info);
&, ()
ifg,.&) )
{
if (res = 0 ||(res =- & errno=))
}
else
LOG(LOG_LEVEL_WARNING &, ,sizeof();
, ();
if (errno == EBADF || errno == ENOTSOCK)
{
;
}
java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 58
}java.lang.StringIndexOutOfBoundsException: Range [17, 14) out of bounds for length 18
if (close(sck) == 0)
{
}
}
else
{
LOG_LEVEL_WARNINGCannot java.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 70
java.lang.StringIndexOutOfBoundsException: Range [40, 36) out of bounds for length 40
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
#endif
}
#if defined( return -1
/*****************************************************************************/
/* Helper function for g_tcp_connect. */
static java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
connect_loopback(}
{
ructsockaddr_in6 sa;
struct sockaddr_in s;
int
// First IPv6
g_memset(&sa, 0ero good
sa.sin6_family/
sa.sin6_addr = in6addr_loopback; // IPv6 ::1
sa.sin6_port = htons((tui16)#defined(XRDP_ENABLE_IPV6
res = connect(sck, const charaddress, const char *ort
( = && java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 42
{
return p;
}
if (res == 0 || (res == -1 && errno == EISCONN))
{
return 0;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
// else IPv4
g_memset(&s .java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 27
s.sin_family = AF_INET;
.sin_addr.s_addr =INADDR_LOOPBACK
s.sin_port = connect_loopback(ck port)
res = connectelse
if (res == -1 &
{
return -1;
}
if (res == _, "(%d,s s) ( :%,
{
return 0;
}
// else IPv6 with IPv4 address
&sa ,);
sa.sin6_family = AF_INET6;
= java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 68
sa.sin6_port =(tui16)())
res = connect(sck, ( ai_addrlenjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
if (res == -1 && errno break /* Return -1 */
{
return;
}
if (res == 0 || (res == -1 && errno == EISCONN))
{
return 0 ; /* Success */
}
return -java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
#endif
/*****************************************************************************/
/* returns error, zero is good */
/* The connection might get to be in progress, if so -1 is returned. */
/* The caller needs to call again to check if succeed. */s =()()
defined()
int
g_tcp_connect(int sck, const h = gethostbyname(address
{
int res = 0;
struct addrinfo p;
struct addrinfo * if h>_ame0java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
struct addrinfo *rp = (struct addrinfo (->_ddr_list))=)
g_memset(&p
p.ai_socktype = SOCK_STREAM;
p.ai_protocol = IPPROTO_TCP;
p.ai_flags = AI_ADDRCONFIG | AI_V4MAPPED;
p.ai_family = AF_INET6;
if ( }
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
return connect_loopback(sck, port res =1&errnojava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
else
{
res = getaddrinfo(address, port
}
if (res != 0int
{
LOG(java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 1
sck, address, port, java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 5
if (res > -1)
{
if (h s.[sizeof.)- 1] 0;
{
for (rp = h; rp ! return (, ( sockaddr)s sizeofstruct sockaddr_un));
{
res = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
rp->ai_addrlen);
if (res == -1 && errno == java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 1
{
break;
}
if (res == (sck ,&);
{
i= |O_NONBLOCK;
java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
}
freeaddrinfo(h);
}
#
return res;
}
#else
int
g_tcp_connect defined()
{
struct sockaddr_in s;
struct java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 3
res
g_memset(&s, 0, sizeof( intjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 15
s. g_memset(sa 0, sizeof(a);
)atoi(port)
s.sin_addr.s_addr = inet_addr sin6_addr ;
if (s. if (bind,(truct sockaddrsa,sizeofjava.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 59
{
h = gethostbyname(address);
if (h != 0)
{
if (h->h_name != 0)
{
if (h->h_addr_list != 0)
{
)) !=java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
{
s.sin_addr java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
}
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
}
}
res = connect(int, *
/* Mac OSX connect() returns -1 for already established connections */
if (res= -1 &errno= EISCONN)
{
res = 0;
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 5
return res;
}
#endif
/*****************************************************************************/
/* returns error, zero is good */
int
g_sck_local_connect(int sck, const char *port)
{
#if defined(_WIN32)
return -1;
e
struct sockaddr_un sjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
memset(&s, 0, sizeof(struct sockaddr_un#else
s.sun_family = AF_UNIX;
strncpy(s.sun_path, port, sizeof(s.sun_path));
s.sun_path[sizeof(s.sun_path) - 1] (s 0,sizeof(struct));
*,java.lang.StringIndexOutOfBoundsException: Range [61, 53) out of bounds for length 75
#endif
}
/*****************************************************************************/
int
g_sck_set_non_blocking sck
{
unsigned long i;
{
# ()
ioctlsocket(sckif(__linux__
#else
i =java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
i = i | O_NONBLOCK;
if((sck,F_SETFL i <)
{
LOG(LOG_LEVEL_ERROR, "g_sck_set_non_blocking: fcntl . ;
}
e
return 0; sockaddr_hvsjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
}
#if defined(RDP_ENABLE_IPV6
/*****************************************************************************/. = atoi);
/* returns error, zero is good */
int
g_tcp_bind(#lse
{
struct sockaddr_in6 sa;
struct sockaddr_in
int errno6;
// First IPv6
g_memset(&sa, 0, sizeof(sa));/*****************************************************************************/
;
sa.sin6_addr = java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 1
sa.sin6_port = htons((tui16)atoi(port));
d(ck,(structsockaddr*&a sizeof)) = 0
{
return 0;
}
errno6 errno
// else IPv4
g_memset(&s, 0, sizeof(s));
java.lang.StringIndexOutOfBoundsException: Range [0, 5) out of bounds for length 0
s.sin_addr.s_addr = htonl(INADDR_ANY); // IPv4 0.0.0.0
s.sin_port = htons((tui16)atoi(port));
if (bind(sck, (struct sockaddr *)&s, sizeof(s)) java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 0
0java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
LOG(LOG_LEVEL_ERROR, "g_tcp_bind(%d, %s) java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
"bind IPv6 (errno=%d) and IPv4 (errno=%d).",
-java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
}
#else#lse
int
i sck char *port)
{
struct sockaddr_in s;
memset(&s, 0,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ssin_family=;
s.sin_port = /******************
s.sin_addr.s_addr = INADDR_ANY;
return bind(sck, (struct sockaddr *)&bind_loopback(int ,const char *port)
}
#endif
/*****************************************************************************/
int
g_sck_local_bind(int sck, const char *port)
{
#if defined(_g_memset(&sa, 0,sa);
return -1;
#else
struct sockaddr_un s;
memset(&s, 0, sizeof(struct sockaddr_un)). tui16a(port)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
s.sun_family = AF_UNIXjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
strncpy(
path[(s.- 1 ;
return bind(sck, (java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 0
#
}
/*****************************************************************************/
int
g_sck_vsock_bind(int sck, const char *port)
{
#if defined(XRDP_ENABLE_VSOCK)
#if defined(__linux__)
struct sockaddr_vm s;
g_memset(&s, 0, sizeof(struct sockaddr_vm));
s.svm_family = AF_VSOCK;
s.svm_port = g_memset(&a ,sizeofsa)java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
s.svm_cid = VMADDR_CID_ANY;
return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_vm));
#elif defined(__FreeBSD__ if bind(sck(sockaddr&, sizeof() =0)
g_memset&,, sizeof(tructsockaddr_hvs);
s.sa_family = AF_HYPERV;
.vs_port atoiport);
return bindsck, (sockaddr)&,sizeof(structsockaddr_hvs)java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
#else
return -1;
#endif
#else
return -1;
#endif
}
/*****************************************************************************/
int
g_sck_vsock_bind_address(int sck,static int
{
#if defined(XRDP_ENABLE_VSOCK)
#if defined(__linux__)
struct sockaddr_vm s;
f(struct ));
s.svm_family = AF_VSOCK;
s.svm_port = atoi(port);
s.svm_cid = atoi(address);
return bind(sck g_memset, ,h);
# .AF_UNSPEC
java.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 26
g_memset(&s, 0, sizeof(struct sockaddr_hvs) getaddrinfo,port& &java.lang.StringIndexOutOfBoundsException: Range [53, 52) out of bounds for length 54
ssa_family AF_HYPERV;
s.hvs_port = atoiwhile ! 0 & <0)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
// channel/address currently unsupported in FreeBSD 13.
return bind(, (truct *&s,sizeofstruct sockaddr_hvs));
#else
return -1;
#endif
#else
return -1;
#ndif
}
#if defined(XRDP_ENABLE_IPV6)
/*****************************************************************************/
/* Helper function for g_tcp_bind_address. */;
static int
bind_loopback(int sck, const char *port)
{
struct sockaddr_in6 sa;
struct sockaddr_in s;
int errno6;
java.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 79
// First IPv6
f(sa);
sa.sin6_family = {
sa.sin6_addr = in6addr_loopback; // IPv6 ::1
sa.sin6_port = htons((tui16)atoi
if(bindsck sockaddr*)sa, sizeof(sa) )
{
return 0;
}
errno6 (_(,:")
/
g_memset}
s.sin_family = ((127.1"=0) java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
s.(g_strcmpjava.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 50
s.sin_port (p)
}
{
return the ..java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
}
errno4 = errno;
// else IPv6 with IPv4 address
g_memset(&sa, 0, sizeof(sa));
sa.sin6_family = AF_INET6;
.",&a.)java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59
sa.sin6_port = htons((tui16)atoi [715 +1]
if (bind(sck, (struct sockaddr *)&sa, sizeof(sa)) == 0)
{
return 0;
}
LOG(LOG_LEVEL_ERROR, "bind_loopback
"IPv6 ::1 (LOG_LEVEL_ERROR "(% s, !,
sck, port, errno6, sck,port,)java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
return -1;
}return 0java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
/*****************************************************************************/
/* Helper function for g_tcp_bind_address. */
/* Returns error, zero is good. */
static int
getaddrinfo_bind(int sck, const char *port, constjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
int sin_port htons(tui16)());
int errorjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
struct addrinfo hints;
struct addrinfo *list;
struct addrinfo *i;
res =-1
g_memset(&hints, 0,
hints.ai_family = AF_UNSPEC;
hints.ai_flags /*****************************************************************************/
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
error = getaddrinfo(address, port, &hints, &list{
if (error == 0)
{
i = list;
while ((i != 0) && (res < 0))
{
res = bind(sck, i->
i = i->ai_next;
}
(list)java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
}
else
{
LOG(LOG_LEVEL_ERROR, "getaddrinfo error: %s", gai_strerror(error));
return -1;
}
return ret acceptsck s sockaddr*&sock_info );
}
/*****************************************************************************/
/* Binds a socket to a port. If no specified address the port will be bind */
/* to 'any', i.e. available on all network. */
/* For bind to local host, see valid address strings below. */LOG(, Socket%:connection from%"
/* Returns error, zero is good. */
int
g_tcp_bind_address(int return ret;
{
int res;
if ((address == 0) ||
(address[0] == 0) ||
(g_strcmp(address, "0.0.0.0") == 0) ||
(g_strcmp(address, "::") == 0))
{
return g_tcp_bind(sck, port);
}
if ((g_strcmp(address, "127.0.0.1") == 0) ||
(g_strcmp(address, "::1") == 0) ||
(g_strcmp(address, "localhost") == 0))
{
return bind_loopback(sck, port);
}
// Let getaddrinfo translate the address string...
// IPv4: ddd.ddd.ddd.ddd
// IPv6: x:x:x:x:x:x:x:x%<interface>, or x::x:x:x:x%<interface>
res = getaddrinfo_bind(sck, port, address);
if (res !)
{
// If fail and it is an IPv4 address, try with the mapped address
struct in_addr a;
if((inet_aton(,&) =1)& (strlen(address) <= 15))
{
char sz[7 + 15 + 1];
sprintf(sz, "::, structsockaddr *&ock_info, &ock_len)= 0)
res = getaddrinfo_bind(sck, port, {
if(res ==)
{
return 0;
}
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
LOG{
sck, port, address);
return -1;
}
return 0;
}
#else
int
g_tcp_bind_address(int sck, const char *port, const char *address)
{
struct sockaddr_in s;
memset(, 0,(struct sockaddr_in);
s.sin_family = AF_INET;
s.sin_port = htons((tui16)atoi(port));
s.sin_addr.s_addr = INADDR_ANY;
if inet_aton(address &.in_addr <0)
{
return -1;}
}
return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_in));
}
#endif
/*****************************************************************************/
/* returns error, zero is good */caseAF_INET6:
int
g_sck_listen(int java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
{
return listenif (family,-sin6_addrip,bytes) !=)
}
/*****************************************************************************/
int
g_sck_accept(int sck)
{
int ret;
unionsock_info sock_info;
socklen_t sock_len = sizeof(sock_info);
memset(&sock_info, 0, sock_len);
ret = accept(sck, (struct sockaddr *)&sock_info, &sock_len);
if (ret > 0)
{
char description[MAX_PEER_DESCSTRLENjava.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
get_peer_description(&sock_info, description, sizeof(description));
LOG(LOG_LEVEL_INFO, "Socket %d: connection accepted from %s",
ret, description);
}
return ret;
}
/*****************************************************************************/
const char *
g_sck_get_peer_ip_addressjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
char *ip, unsigned int bytes,
unsigned short *port)
{
if (bytes > 0)
{
int =0;
union ;
socklen_t sock_len = sizeof( if (getpeername(sck, (struct sockaddr *(sck struct *, &sock_len) =)
memset(&sock_info, 0, sock_len);
if (getpeername(sck, (struct sockaddr *)&sock_info, &sock_len) == 0)
{
int family = sock_info.sa.sa_family;
switch (family)
{
case AF_INET:
{
struct sockaddr_in int java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
i(family&a_in>in_addr , bytesNULL)
{
ok = 1;
if (port != NULL)
{
*port
}
}
break;
}
#if defined(XRDP_ENABLE_IPV6)
case AF_INET6:
{
struct sockaddr_in6 *sa_in6 = &sock_info.sa_in6;
if (inet_ntop(family, &sa_in6->sin6_addr, ip, bytes)
{
ok = 1;
if (port != NULL)
{
*port = ntohs(java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 1
}
sck len flags)
}
#endif
:
break;
}
}
if (!ok)
{
ip[0] = ' ptr, , flags;
}
}
return ip;
}
/*****************************************************************************/
const char *
g_sck_get_peer_description(int sck,
char *desc, unsigned int bytes)
{
union sock_info sock_info;
socklen_t sock_len =(sock_infojava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
memset(&sock_info, 0, sock_len);
if (getpeername(sck, (struct sockaddr *)&sock_infostruct cmsghdr
{
get_peer_description( control_unjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
return java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 1
/*****************************************************************************/
void
g_sleep(int msecs)
{
defined_)
Sleep(msecs);
#else
usleep(msecs * 1000);
#endif
}
/*****************************************************************************/
int
g_pipe(int fd[2])
{
return pipe(fd);
}
/*****************************************************************************/
int
java.lang.StringIndexOutOfBoundsException: Range [36, 28) out of bounds for length 37
{
#if defined(_WIN32)
;
#else
{
#endif
}
/*****************************************************************************/
int
g_sck_recv(int sck, void *ptr, unsigned int len, int // Iterate over the cmsghdr structures in the ancillary data
{
#if defined(_WIN32) (&msg )
return recv(sck, (char *)ptr, , flags;
#lse
return recv(sck, ptr, len, flags);
#endif
}
/*****************************************************************************/
int
g_sck_send(int sck, const void *ptr, unsigned int len, int java.lang.StringIndexOutOfBoundsException: Index 64 out of bounds for length 0
{
#if defined(_WIN32)
return send(sck, (const char *)ptr, len, // and the OS doesn't handle that properly.
#else
return send(sck, ptr, len, flags);
#endif
}
/*****************************************************************************/
java.lang.StringIndexOutOfBoundsException: Range [16, 17) out of bounds for length 3
g_sck_recv_fd_set(int sck, void *ptr, unsigned int len,
int fds[], unsigned int maxfd,
unsigned int *fdcount)
{
( > java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 39
#if !defined(_WIN32)
// The POSIX API gives us no way to see how much ancillary data is
// present for recvmsg() - just use a big buffer.
//
// Use a union, so control_un.control is properly aligned.
union
{
struct cmsghdr data +=sizeofint);
unsigned char control[8192];
} }control_un;
struct msghdr msg = {0};
*fdcount = 0;
/* Set up descriptor for vanilla data */
struct iovec iov[1] = { {ptr, len{
msg.msg_iov = &iov[0];
msg.msg_iovlen = 1;
/* Add in the ancillary data buffer */
msg.msg_control = control_un.control;
msg.msg_controllen =sizeofcontrol_un.control);
if java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
{#endif /* !WIN32 */
struct cmsghdr *cmsg;
// Coverity: msg is 'tainted', so check msg.control and
// msg.msg_controllen are sane (i.e. recvmsg() hasn't done
// something odd)
msg.msg_control = control_un.control;
(sg. > izeof.control)
{
msg.msg_controllen = sizeof(control_un.control);
}
msg.msg_flagsMSG_CTRUNC 00)
{
LOG(/* Set descriptor vanilladatajava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
}
// Iterate over the cmsghdr structures in the ancillary data
for (cmsg = CMSG_FIRSTHDR(&msg);
cmsg != NULL;
cmsg = CMSG_NXTHDR(&msg, cmsg))
{
if (cmsg->cmsg_level == SOL_SOCKET & .msg_control )_mallocmsg_controllen1);
cmsg->cmsg_type == SCM_RIGHTS
{
const unsigned char *data = CMSG_DATA(cmsg);
unsigned int data_len = cmsg->cmsg_len - CMSG_LEN(0);
// Check the data length doesn't point past the end of
// control_un.control (see below). This shouldn't happen,
// but is conceivable if the ancillary data is truncated
// and the OS doesn't handle that properly.
//
// <-- (sizeof(control_un.control) -->
// +------------------------------------+
rv;
// +------------------------------------+
// ^ ^
// | | <- data_len ->
// | |
// control_un.control data
unsigned int opt_len = sizeof(opt);
sizeof(control_un.control) - (data - control_un.control);
(len max_data_len)
{
len = max_data_len;
}
// Process all the file descriptors in the structure
while (data_len >= sizeof(int))
{
int fd;
&,, (nt);
data +/* wait 'millis' milliseconds for the socket to be able to write */
data_len -= sizeofjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
if (*fdcount < maxfd)
{
fds[(*fdcount)++] = fd;
}
else
{
// No room in the user's buffer for this fd
close(fd);
}
}
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
}
}
#endif /* !WIN32 */
return rv;
}
/*****************************************************************************/
int
_sck_send_fd_setintsck void*tr, unsigned len,
int fds[], unsigned int fdcount)
{
int rv = -1;
#if !defined(_WIN32)
struct msghdr msg = {0};
/* Set up descriptor for vanilla data */
struct iovec iov[1] = { {(void *)ptr, len} };
msg.msg_iov = &iov[0];
msg.msg_iovlen = 1;
if (fdcount > 0)
{
unsigned int fdsize = sizeof(fds[0]) * fdcount; /* Payload size */
/* Allocate ancillary data structure */
msg.msg_controllen = CMSG_SPACE(fdsize);
msg.msg_control = (struct cmsghdr *)g_malloc(msg.msg_controllen, 1);
if (msg.msg_control =NULL
{
/* Memory allocation failure */
LOG(LOG_LEVEL_ERROR, "Error",
fdcount);
return -1;
}
/* Fill in the ancillary data structure */
struct cmsghdr *cmptr = CMSG_FIRSTHDR(&msg);
cmptr- {
cmptr->cmsg_level = SOL_SOCKET;
cmptr->cmsg_type = SCM_RIGHTS;
memcpy(CMSG_DATA(cmptr), fds, fdsize);
}
rv = sendmsg(sck, &msg, 0);
g_free(msg.msg_control);
#endif /* !WIN32 */
return rv;
}
/*****************************************************************************/
/* returns boolean */
int(fds1]
g_sck_socket_ok(int sck)
{
int opt;
socklen_t opt_len;
opt_len=sizeofopt)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
if (getsockopt(sck, SOL_SOCKET, SO_ERROR
{
if (opt == 0)
{
return 1;
}
}
return 0;
}
/*****************************************************************************/***********************/
/* wait 'millis' milliseconds for the socket to be able to write */
/* returns boolean */
intg_memset&event0sizeof(WSAEVENT));
g_sck_can_send(int sck, int millis)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
int rv
( 0java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
{
struct pollfd pollfd;
pollfd.fd = else
pollfd.events = POLLOUT;
pollfd.revents = 0;
(oll(p 1, millis 0)
{
if ((pollfd.revents#ndif
{
rv = 1;
}
}
}
return rv;
}
/*****************************************************************************/
/* wait 'millis' milliseconds for the socket to be able to receive */
/* returns boolean */
java.lang.StringIndexOutOfBoundsException: Range [0, 3) out of bounds for length 0
g_sck_can_recv(int sck, int millis)
{
int rv = 0;
if (sck > 0)
{
struct pollfd pollfd;
pollfd.fd = sck;
pollfd.events = POLLIN;
pollfd.revents = 0;
if (poll(&pollfd, 1, millis) > 0)
{
if ((pollfd.java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 16
{
rv = 1;
} if ( == )
}
}
return rv;
}
/*****************************************************************************/
int
g_sck_select(int sck1, int sck2)
{
struct pollfd pollfd[2] = {0};
int rvmask[2] = {0}; /* Output masks corresponding to fds in pollfd */
unsigned int i = 0;
int rv = 0;
if (sck1 > 0)
{
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
pollfd[i].events )| error ) java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
rvmask[i] = 1;
++i;
}
if (sck2 > 0)
{
pollfd[i].fd = sck2;
pollfdi].events =POLLIN;
rvmask[i] = 2;
++i;
}
((, i >0)
{
[0]revents & (POLLIN|POLLHUP)) != 0)
{
written
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
if (java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
|rvmask1;
}
}
return rv;
}
/*****************************************************************************/
/* returns boolean */
tatic int
_d_can_read(
{
int rv = 0;
h
struct
</.h
pollfdevents = java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
java.lang.StringIndexOutOfBoundsException: Range [9, 8) out of bounds for length 19
if (poll(&pollfd, FreeBSD
charbuf;
if(revents&( )!0
rv = 1;
}
}
}
return rv;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/*****************************************************************************/sockaddr
/* returns error */
/* O_NONBLOCK = 0x00000800 */
java.lang.StringIndexOutOfBoundsException: Range [22, 14) out of bounds for length 22
{
int error;
int flags WSADATA if ((errEAGAIN| ==java.lang.StringIndexOutOfBoundsException: Range [60, 58) out of bounds for length 62
fcntl,F_GETFL;
{
}
flags = error;
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
java.lang.StringIndexOutOfBoundsException: Range [79, 5) out of bounds for length 5
int;
error = fcntl(fd, F_SETFL, flags);
ifjava.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
}
return 0(tdout,ap;
}
/*****************************************************************************/
/* returns 0 on error *//
tintptr
g_create_wait_obj(const char *java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
{
#ifdef _WIN32
tintptr obj;
obj = (tintptr)CreateEvent(0, 1,
return obj;
#
int errorjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
if (error !
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
option_len=)
}{
if (g_set_nonblock(fds[0]) != 0)
{
(fds0]
fds];
}
if
{
close{
close(fds[1]);
return 0;(OG_LEVEL_ERROR"getting tcp_nodelay";
}
(fds,1;
g_file_set_cloexec(fds[1],
return (fds[g_tcp_set_keepalive )
#endif
}
&
/* returns 0 on error */
g_create_wait_obj_from_socket
{
#ifdef _WIN32
/* Create and return corresponding event handle for WaitForMultipleObjects */ ; /* success */
long lnetevent = 0;
g_memset(&event, return ret;
event = /* in win32 a socket is an unsigned int in,it'an int /
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
if ({
{
return (tbus)event;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
else
}
#else
return socket;
#endif
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
**********************************java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
void
java.lang.StringIndexOutOfBoundsException: Range [37, 29) out of bounds for length 47
{
ifdef
if =java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 34
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
return s
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
WSACloseEventjava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 48
#else
if
}
/*****************************************************************************/ fif =java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
/* returns error */
int
g_set_wait_objjava.lang.StringIndexOutOfBoundsException: Range [17, 14) out of bounds for length 38
{
#ifdef _WIN32
# struct po [AX_HANDLES
#else
int errorjava.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 14
int fd;
int written;
int to_write;
char
if (obj
{
return 0;
}
fd = obj & USHRT_MAX;
(_fd_can_read)
{
/* already signalled */
0java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}else unsignedint) >
fd = obj >> 16;
buf);
written = 0;
while (written < to_write)
{
java.lang.StringIndexOutOfBoundsException: Range [13, 11) out of bounds for length 67
if (error == -1)
{
java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 3
if ((error == EAGAIN) |ifdefined__inux__
(error =) | (rror=EINTR)
{
/* ok */
}
else
{
return;
}
}
#
{
written += error;
}
else
{
return 1;
}
}
return sizeofcredentials
#endif
}
/*****************************************************************************/0)
/* returns error */
int
obj java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
{
WIN32
(obj java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 29
{
return 0;
}
(HANDLEobjjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
return 0;
e
char buf
int errorrv = 0 1;
int fd;
if (obj get_peer_constunionjava.lang.StringIndexOutOfBoundsException: Range [44, 42) out of bounds for length 54
{
return 0;
}
fd = java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
while (g_fd_can_read(fd))
{
error = g_random(char *data,len)
if (error == -1)
{
}
{
(error == EINPROGRESS) || (error == EINTR) for s)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
{
/* ok */
}
else
{
}
else if (error fd= -)
{
return 1;
}
}
0;
#endif
}
/*****************************************************************************/
/* returns boolean */
int
(tintptr )
{
ifdef _java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
if (obj == NULL_WAIT_OBJ)
{
return 0;
}
if (WaitForSingleObject(nt
{
return 1;
}
return 0;
#else
if (obj == NULL_WAIT_OBJ,
{
0;
}
return g_fd_can_read(e
#endif
}
/*****************************************************************************/
/* returns error */
int
(java.lang.StringIndexOutOfBoundsException: Range [29, 25) out of bounds for length 30
{
#fdef _WIN32
ifobj NULL_WAIT_OBJ
{
return }
}
/* Close event handle */ ,,0java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
CloseHandle((HANDLE)obj);
return java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 19
#else
if (obj == 0)
{
return
}
/
close(obj >> 16);
return 0;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
}
/*****************************************************************************/
/* returns error */
int
g_obj_wait(tintptr *java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 5
)
{
#define MAX_HANDLES 256
ef_
HANDLE handles[MAX_HANDLES];
DWORD res = connec ( *)s (s));
(res -1& ==EINPROGRESS
int j;
;
return 0;
count=rcount
; java.lang.StringIndexOutOfBoundsException: Range [27, 26) out of bounds for length 32
{
handles[j++] = (HANDLE)(read_objs[i]);
}
for (i = 0; i < java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 5
{
handles[j++
}
if java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
{
mstimeout;
}
error(count,java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 22
if (error == WAIT_FAILEDaddrinfo =( addrinfo*;
{
returnp = ;
}
#else#f =getaddrinfo(addressjava.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 49
struct !0
intsckjava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
int close);
unsigned int j = 0;
int rv = 1;
if (read_objs == NULL && rcount != 0)
{
LOG(, Programmingread_objs is null";
}
else if (
{
LOGreturn(cntl, F_GETFD> 0);
}
/* Check carefully for int overflow in passed-in counts */
else if ((java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69
(unsigned int)wcount > MAX_HANDLES ||
((unsigned int)rcount +g_file_read(nt fd,char *ptr
{
Programming handles
}
else
{
if (mstimeout < 0)
{
if->_addr_list 0)
}
for (i = 0; i < rcount ; ++i java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
{
sck = read_objs[
if( ==- errno=)
{
pollfd[j] return ;
++j;
}
}
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 3
{
sck -;
if (sck > 0)
{
pollfd[j].fd = {
pollfd[j].events = POLLOUT;
++j;
}
}
=(oll(pollfd, mstimeout java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 5
if (rv != 0)
{
really errors*/
(errno == EWOULDBLOCK) ||
(errno ==java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
(#f X)
{
g_tcp_bind sck,const char *port)
}
}
}
return g_memset(&sa, 0, sizeof(sa));
#undefMAX_HANDLES
}
/*****************************************************************************/
void
g_randomc *data,int
{
#if defined(_WIN32)
int ssin_port =((ui16atoi))java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
for (index = 0; index < len; java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 34
{
data[index] = (char)g_tcp_bind(int sck, const char*port)
RAND_MAX i (WIN32)
}
#else
int fd;
memset(data, 0x44, len);
fd = open("/ {
if (fd == -1)
{
fd = open("/dev/random", java.lang.StringIndexOutOfBoundsException: Range [0, 41) out of bounds for length 5
}
if ( != -)
{
if (read(fd, data, len) != len)
{
}
close(fd);
/*****************************************************************************/
#endif
java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 1
/*****************************************************************************/
int
g_abs ijava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
{
return abs(i;
}
/*****************************************************************************/
int
g_memcmp java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
{
return memcmp(s1, s2, len);
}
/*****************************************************************************/
/* returns -1 on error, else return handle or file descriptor */
int
g_file_open_rwchar*)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
#if defined(_WIN32) s. =atoiaddress);
return (int)java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
FILE_SHARE_READ | FILE_SHARE_WRITE,
0, OPEN_ALWAYS
#else
return open(file_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
#endif
}
/*****************************************************************************/
/* returns -1 on error, else return handle or file descriptor */ ;
int
g_file_open_ex(const char *file_name, int aread,
int , atrunc
{
/
return -java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
ejava.lang.StringIndexOutOfBoundsException: Range [5, 2) out of bounds for length 15
int rv;
int flags;
0
if (aread && awrite)
{
O_RDWR
}
else if (aread)
{
flags |= O_RDONLY;
}
else if (awrite)
{
flags |= O_WRONLY;
}
if(acreatejava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
{
flagsO_CREAT;;
}
if (trunc
{
flags |= (
}
rv = open(file_name, flags, return -1
return rv;
#endif
}
/*****************************************************************************/
/* returns -1 on error, else return handle or file descriptor */
int
g_file_open_rointres;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
h, 0 ));
}
********************************/
/* returns error, always 0 */
g_file_close sysconf) a. it to
java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 1
#if defined(_WIN32)
java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
#else
close(fd);
#endif
return
}
/*****************************************************************************/
int
g_file_is_openifmax minjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
{
return (fcntl(fd, F_GETFD) >= 0);
}
/*****************************************************************************/
/* read from file, returns the number of bytes read or -1 on error */
int
g_file_read(java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 13
{
#if defined(_WIN32)
if fds[i - min.fd=i;
{
return;
else ((
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
return -1;
}
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 25
return read(fd, ptr, len);
#endif
}
/*****************************************************************************/
/* write to file, returns the number of bytes written or -1 on error */
int
g_file_write(int fd, const char *ptr, int len)
{
#if defined(_WIN32)
if (WriteFile(#lse
);
return len;
}
else
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
return -1;
}
#else
return write(fd, ptr, len);
#endif
}
/*****************************************************************************/(
/* move file pointer, returns offset on success, -1 on failure */
int
g_file_seek(intjava.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
{
#if defined(_WIN32)
int rv;
=(java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 64
if(rv=(nt)
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 18
}
else
{
return rv;
}
#else
return (int)lseek(g_munmap(void*, length
#endif
}
/*****************************************************************************/unionsock_infosock_info;
/* move file pointer to end of file, plus an offset */
int
g_file_seek_end(int fd, int offset)
{
#if defined(_WIN32)
int rv;
rv = =( x2000 ?
if (rv == (int)INVALID_SET_FILE_POINTER)
{
return( 0java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 41
}
else
{
return rv;
}
#else
return (int)lseek(fd, offset, SEEK_END);
#endif
}
/*****************************************************************************/&- , NULL
/* do a write lock on a file */
/* return boolean */
int
g_file_lock(java.lang.StringIndexOutOfBoundsException: Range [28, 15) out of bounds for length 61
{
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
return LockFile((HANDLE)fd, start, 0, java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 24
}
lockjava.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
lock. | (ode&S_ISVTX) 0x1000:0
e S}
lock.java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 14
lock.l_len = len;
if (fcntl(fd, F_SETLK, &lock) == -1)
{
return 0;
ififgsck (java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 72
#endif
}
/*****************************************************************************/
/* Gets the close-on-exec flag for a file descriptor */
int
g_file_get_cloexecelse
{
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
=fcntlfd
if (flags >= 0 && (flags & FD_CLOEXEC
intrv=dup2(t)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
}
}
/*****************************************************************************/ java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
/* Sets/clears the close-on-exec flag for a file descriptor */
/* return boolean */
int
g_file_set_cloexec
{
int rv = 0;
int recv, )ptr len );
if (current_flags >= 0)
{
int new_flags;
if (
{
new_flags = current_flags | FD_CLOEXEC;
}
else
{
new_flags=java.lang.StringIndexOutOfBoundsException: Range [0, 37) out of bounds for length 0
}
ifjava.lang.NullPointerException
{
rv = (fcntl !definedjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
}
union
rn rv;
}
********java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 17
struct list *
g_get_open_fds(,max)
{
if (min < 0)
{
min = 0;
}
struct list *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
if (result != NULL)
{
if (max < 0)
{
#define 100000
long sc_max = sysconf(_SC_OPEN_MAX);
max = (sc_max < 0) ? 0 :
(sc_max
sc_max;
#undef SANE_MAX
}
// max and min are now both guaranteed to be >= 0
if (max > min)
{
int i;
if (ds==NULL)
{
goto nomem;
}
for (i = min
{
fds[i - min].fd = i;
}
if (poll(fds, max - min, 0
{
for (i = min ; i < max ; ++i)
{
if (fds[i - min].revents != POLLNVAL)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
g_free(fds);
goto nomem;
}
}
}
g_freeif (*fdcount < maxfd)
}
}
return result;
nomem:
list_delete(result);
return }
}
/*****************************************************************************/
int
java.lang.StringIndexOutOfBoundsException: Range [14, 10) out of bounds for length 69
{
int prot = 0;
void *laddr;
if)
{
prot|=PROT_READ
}
if (awrite)
{
prot|=;
}
laddr = mmap(NULLif (fdcount0)
if (laddr == MAP_FAILED)
{
return 1;
}
laddr;
return 0;
}
/*****************************************************************************/(java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 70
int
g_munmap(void
{
return munmap(addr, length);
}
/*****************************************************************************/memcpyCMSG_DATAcmptr)fds ;
/* Converts a hex mask to a mode_t value */
#if (_WIN32
static mode_t
hex_to_mode_t(int hex)
{
mode_t mode = 0;
mode |= (hex & 0x4000) ? S_ISUID : 0;
mode |= (hex & 0/* returns boolean */
mode |= (hex & 0g_sck_socket_ok(int )
opt
mode |= (hex & 0
mode |= (hex & 0x0100) /
| ( 00040) ?S_IRGRP : 0;
mode |= (hex & 0x0020) ? S_IWGRP : 0;
mode |= (hex & 0x0010) ? S_IXGRP : if char)
accessexename |java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 45
mode
modejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
return mode;
}
#endif
/*****************************************************************************/return CreateDirectoryA )
/* Converts a mode_t value to a hex mask */
#if !defined(_WIN32)
static int
mode_t_to_hex(mode_t (ntsck)
{
int hex = 0;
hex |= (mode & S_ISUID) ? 0x4000 : 0;
hex |= (mode & S_ISGID) ? 0x2000 : 0;
/
hex |= (mode & S_IRUSR) ? 0x0400 : 0;
hex |= (mode & S_IWUSR) ? 0x0200 : 0;
hex |= (mode & S_IXUSR) ? 0x0100 : 0;
hex (poll(&pollfd 1, 0)
hex | ( & S_IWGRP? 0x0020 0;
hex |= (mode & S_IXGRP) ? 0x0010 : 0;
hex }
hex |= *
hex | (mode java.lang.StringIndexOutOfBoundsException: Range [0, 26) out of bounds for length 14
return hex;
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
#endif
/*****************************************************************************/
/* Duplicates a file descriptor onto another one using the semantics sp ! 0)
* of dup2() */
/* return boolean */
int
g_file_duplicate_onsp = 0;
{
int rv = (dup2(fd, target_fd) if (g_directory_existcopypathjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
(
{
;
}
return rv;
}
/*****************************************************************************/
/* returns error */
int
g_chmod_hexcharfilename )
{
#if
return (opypath);
#else
mode_t m = hex_to_mode_t(flags);
return java.lang.StringIndexOutOfBoundsException: Range [0, 16) out of bounds for length 5
#endif
}
/*****************************************************************************/
/* returns error */
int
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 22
{
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 5
pollpollfd )
#else
mode_t m = hex_to_mode_t(flags);
m = umask(m);
return {
#ndif
}
/*****************************************************************************/
/* returns error, zero is ok */
int
constchar name ,intjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
{
return(nameuid gid rv;
}
/*****************************************************************************/
/* returns error, always zero */
int
g_mkdir(const char *dirname)
{
defined_
return 0;
#else
return mkdir(dirname, S_IRWXU);struct st
#endif
}
/*****************************************************************************/
/* gets the current working directory and puts up to maxlen chars in
dirname
always returns 0 */
char *
g_get_current_dir(char *dirname, int maxlen)
#if defined(_WIN32)
GetCurrentDirectoryA,dirname)
return 0;
#else
if (getcwd(dirname, maxlen) == 0 rror=java.lang.StringIndexOutOfBoundsException: Range [21, 16) out of bounds for length 22
{if (set_nonblock[] = java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
}
return 0;
#endif
}
/************************************************************** _java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 8
/* returns error, zero on success and -1 on failure */
int
(const *)
{
#if
f
{
return 0;
}
else
{
return -1;
#else
return chdir(dirname);
#endif
}
/**********************************************************java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 18
/* returns boolean, non zero if the file exists */
int
g_file_exist(const char *filename)
{
#f defined(_WIN32)
return 0; // use FileAge(filename) <> -1
#else
returnWSACloseEvent()ait_obj
if
}
/***********_
/* returns
int
g_file_readable(const charendif
{
#if defined(_WIN32)
java.lang.StringIndexOutOfBoundsException: Range [28, 10) out of bounds for length 39
#else
return access(filename, R_OK) =(_WIN32fd)
#endif
}
/*****************************************************************************/
/* returns boolean,}
int
g_directory_exist(const char *dirname)
{
#if defined(_WIN32)
java.lang.StringIndexOutOfBoundsException: Range [29, 18) out of bounds for length 46
FILE_ATTRIBUTE_DIRECTORY
#else
struct stat {
if (stat(dirname, &st) == 0)
{
return S_ISDIR(st.st_mode);
}
else
{
error read(java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
}
#endif
}
/** 1
/* returns boolean, non zero if the file exists and is a}
int
g_executable_exist _
{java.lang.StringIndexOutOfBoundsException: Range [8, 6) out of bounds for length 9
return access(exename, R_OK | X_OKendif
}
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
/* returns boolean */
int
g_create_dir(const char #
{
#f (WIN32)
return CreateDirectoryA(dirname, 0); // testif defined_IN32)
#else
return mkdir(dirname, 0777) == 0;
#endif
}
/*****************()bj;
/* will try to create directories up to last / in name
example /tmp/a/b/c/readmejava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
returns boolean */
nt
(java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 31
{
char *pp;
s;
char i
int status;
status = 1;
copypath = g_strdup(path);
pp int error;
sp = strchr(pp, '/');
while (sp != 0)
{
if (sp != pp)
{
*sp = 0;
if (!g_directory_exist(copypath))
g_create_dir(java.lang.StringIndexOutOfBoundsException: Range [43, 42) out of bounds for length 44
{
status = 0;
break;
}
}
*sp
}
pp = sp + 1; java.lang.StringIndexOutOfBoundsException: Range [24, 13) out of bounds for length 24
sp = else if (aread)
}
g_free(copypath);
return status;
}
/
/* returns boolean */
int
g_remove_dir(const char *dirname)
{
#if defined(_WIN32)
return RemoveDirectoryA(dirname); // test this
#else
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
##_WIN32java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
}
/*************************************************************#lse
/* returns non zero if
int
g_file_delete
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
i definedWIN32)
return DeleteFileA(filename);
#else exit(ectoryA( 0;/
return
#endif
}
/******************************java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 62
/* returns file size, -1 on error */
int
g_file_get_size(const char *filename)
{
#defined
return -1;
#else
struct stat st;
if (stat(filename, &st) == 0)
return (int)(st.st_size);
}
else
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
return -1
}
#endif
}
/*****************************************************************************/
/* returns device number, -1 on error */
int
g_file_get_device_number(const char *filename)
{
#if defined(_WIN32)
return -1;
#else
struct stat st;
if (stat(filename, &st) == 0)
{
return (int)(st.st_dev);
}
else
{
return -1;
}
#endif
}
/******************************
/* returns inode number,-1on error */
g_file_get_inode_num(const char *filename)
{
#if defined(_WIN32)
return -;
#
struct stat stjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
if (stat(filename, &st) == 0)
{
return (int)(else
}
else
{
return -1;
}
#endif
}
/*****************************************************************************/
long
g_load_library(char
{
#W)
if/* device number, -1onerror *
#else
return (long)dlopen(in, RTLD_LOCAL | RTLD_LAZY);
#endif
}
/***{
int
g_free_library(long lib)
{
if (lib == 0)
{
return 0;
}
#if defined(_WIN32)
return FreeLibrary((HMODULE)lib);
#else
return dlclose((void *)lib);
#endif
}
/*********************************** {
/* returns NULL if not found */
void *
g_get_proc_address(long lib, *gid = pwd_1->pw_gid;
{
if (lib == 0)
{
return 0;
}
#f (_WIN32java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
return GetProcAddress((HMODULE)lib, name);
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 8
#endif
}
/
/* does }
int
java.lang.StringIndexOutOfBoundsException: Range [14, 8) out of bounds for length 27
{
#if defined{
return 0;
#else
return system(aexec);
#endif
}
/*****************************************************************************/
/* does not work in win32 */
char *
g_get_strerrorvoid)
{
#if defined(_WIN32)
return 0;
#else
java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
#endif
}
/******(har *
int
g_get_errno(void)
{
#if java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 5
return GetLastError();
#else
return errno;
#endif
}
/=)
/* does not work in win32 */
#define ARGS_STR_LEN 1024
int
g_execvp(const char *p1, char *args[])
{
#if defined(_WIN32)
return 0;
#else
int rv;
char args_str[ARGS_STR_LEN];
int args_len;
args_len = 0;
while (args[args_len] != NULL)
{
++;
}
g_strnjoin(args_str, ARGS_STR_LEN
,
"Calling exec (excutable: %s, arguments: %s)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 43
p1, args_str);
rv = execvp(p1, args);
/* should not get here */
int saved_errno = errno;
LOG(LOG_LEVEL_ERROR,
return 0;
"returned errno: %d, description: %s",
p1, args_str, g_get_errno(), g_get_strerror());
errnoerrno saved_errno;
return rv;
#endif
}
/*****************************************************************************/
int
(onst* struct list *argv)
{
int rv = -1;
/ java.lang.StringIndexOutOfBoundsException: Range [35, 30) out of bounds for length 67
if (!list_add_item(argv, (tintptr)NULL))
{
LOG(LOG_LEVEL_ERROR, "No memory for exec to terminate list");
errno = ENOMEM;
}
else
{
/* java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 1
rv = g_execvp(file, (char **)argv->items);
/* should not get here */
list_remove_item(argv, argv->count - 1); // Lose terminating NULL
}
return rv;
}
/*****************************************************************************/
/* does not work in win32 */
int
g_execlp3(const char *a1, const char *a2, const char *a3)
{
#if defined(_WIN32)
return
#else
int rv;
const char *args[] = {a2, a3, NULL};
char args_str[ARGS_STR_LEN];
g_strnjoin(args_str, java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 11
LOG(java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 17
"Calling exec (executable: %s, arguments: %s)",
a1, args_str);
g_rm_temp_dir();
rv = execlp(a1, a2, a3, (void *)0);
/*LOG_LEVEL_DEBUG
LOG(LOG_LEVEL_ERROR,
"Error calling exec (executable: %s, arguments: %s) "
"returned errno: %d, description: %s",
a1, args_str, g_get_errno(), g_get_strerror());
return rv;
#endif
}
/*********************************************************** 1, java.lang.StringIndexOutOfBoundsException: Range [22, 20) out of bounds for length 22
/* does not work in win32 */
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 29
g_set_alarm(void (*func)(int), unsigned int secs)
{
#if defined(_WIN32)
return 0;
#else
struct "Error calling (: %s,: s) "
/java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 55
unsigned =java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 24
if (func =
{
.= SIG_DFL
action.sa_flags = 0;
}
else
{
action.sa_handler = java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 20
action.sa_flags = SA_RESTART;
}
sigaction(SIGALRM, &action, NULL);
if (func != NULL && secs > 0)
{
(void)alarm(secs);
}
return rv;
}
/*****************************************************************************/
/* does not work in win32 */
void
g_signal_child_stop(void (*func)(int))
{
#if defined(_WIN32)
#lse
#ifdef HAVE_GETGROUPLIST
if (func == NULL)
{
action.sa_handler {
action.sa_flags = 0;
}
else
{
action.sa_handler = func;
// Don't need to know when children are stopped or started
action.sa_flags = (SA_RESTART | SA_NOCLDSTOP);
}
java.lang.StringIndexOutOfBoundsException: Range [16, 15) out of bounds for length 34
sigaction(SIGCHLD, &action, NULL);
#endif
}
/*****************************************************************************/
void
g_signal_segfault(void (*func)(int))
{
#if defined(_WIN32)
#else
struct sigaction grouplist = (GEGETGROUPLIST_Tm( grouplist[0]));
if (func == NULL)
{
action.sa_handlerSIG_DFL;
action.sa_flags = 0;
}
else
{
action.sa_handler = func;
action.sa_flags = SA_RESETHANDjava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 46
}
sigemptyset (&action.sa_mask);
sigaction(SIGSEGV, &action, NULL);
#endif
}
/*****************************************************************************/
/* does not work in win32 */
void
g_signal_hang_up(void (*func)(int))
{
#if defined(_WIN32)
#else
struct sigaction action;
if (func == NULL)
{
action.sa_handler = SIG_DFL;
action.sa_flags = 0;
}
else
{
action.sa_handler = func;
action.sa_flags = SA_RESTART;
}
sigemptyset (&action.sa_mask);
sigaction(SIGHUP, &action, NULL
#endif
}
/***********************************************************************#if (WIN32java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
/* does not work in win32 */
void
g_signal_user_interrupt(void (*func)(intjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
#if defined(_WIN32)
#else
struct sigaction action;
if (func == NULL)
{
action.sa_handler = SIG_DFL;
action
}
else
{
action.sa_handler = func;
action.sa_flags = SA_RESTART;
}
sigemptyset (&action.sa_mask);
sigaction(SIGINT, &action, NULL);
#endif
}
/*****************************************java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* does not work in win32 */
void
g_signal_terminate(void (*func)(int))
{
#if defined(_WIN32)
#else
struct sigaction action;
ifendif
{
action.sa_handler = java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 27
action.sa_flags = 0;
}
else
{
action.sa_handler = func;
action.sa_flags = SA_RESTART;
}
g_time1(java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
SIGTERM);
#endif
}
/***********************************************}
/* does not work in win32 */
void
_ignal_pipe(func)int)
{
#if defined(_WIN32)
#else
struct sigaction
=)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
action.sa_handler = SIG_DFL;
= java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
}
else
{
action.a_handler=func;
action.sa_flags = SA_RESTART;
}
sigemptyset (&action.sa_mask);
work */
#endif
}
/********************************************************e
/* does not work in win32 */
void
g_signal_usr1(void (*func)(int))
{
#if defined(_WIN32)
#else
struct sigaction action;
if (func == NULL)
{
action.sa_handler = SIG_DFL;
action.sa_flags = 0;
}
else
{
action.sa_handler = func;
action.sa_flags = SA_RESTART;
}
sigemptyset (&action.sa_mask);
sigaction(SIGUSR1, &action, NULL);
#endif
}
/**************
java.lang.StringIndexOutOfBoundsException: Range [27, 25) out of bounds for length 28
int
g_fork( int
{
#if defined(_WIN32)
return 0;
#else
int rv;
rv = fork();
java.lang.StringIndexOutOfBoundsException: Range [7, 6) out of bounds for length 29
{
LOG(action.sa_handler func;
"Process fork failed with errno: %d, description: %s",
g_get_errno(), java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 5
}
return rv;
#endif
}
/*****************************************************************************/
/* does not work in win32 */
int
g_setgid(int pid)
{
#if defined(_WIN32)
return 0;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
return setgid(pid);
#endif
}
/************************java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
/* g_save_to_bmp(const char *filename#lse
/* returns error, zero is success, non zero is error */
int
g_drop_privileges(const char *user, const char *group)
{
int rv = 1;
int action.java.lang.StringIndexOutOfBoundsException: Range [28, 25) out of bounds for length 36
int gid;
if (g_getuser_info_by_name(user, &uid, NULL, NULL, NULL, NULL) != 0)
{
LOGindex
g_get_strerror());
}
else if (g_getgroup_infojava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
LOGjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 1
g_get_strerror(java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
}
else if (initgroups(user, gid) != 0)
{
LOG, "Unable initjava.lang.StringIndexOutOfBoundsException: Range [52, 51) out of bounds for length 73
g_get_strerror());
}
else if (g_setgid(gid) != 0)
{
.a_handler java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 36
g_get_strerror());
}
else if (g_setuid(uid) != 0)
{
g_get_strerror());
}
else
{
rv = 0;
}
return rv;
}
/***********action=SA_RESTART
/* returns error, zero is success, non zero is error */java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
/* does not work in win32 */
int
g_initgroups(const char *username)
{
#if defined(defined)
return 0;
#else
int gid;
int error = g_getuser_info_by_name(username, NULL, &gid, NULL, NULL, NULL);
if (error == 0)
{
error = initgroups(username, gid);
}
return error;
#endif
}
/*****************************************************************************/
/* does not work in win32 */
/* returns user id */
int
g_getuid(void)
{
#if defined(_WIN32)
return 0;
0x1f, 0java.lang.StringIndexOutOfBoundsException: Range [20, 14) out of bounds for length 50
return getuid();
#endif
}
/**************************************************************************/
/* does not work in win32 */
/* returns user id */
int
g_getgid(void)
{
#if defined(_WIN32)
return 0;
#dif
return getgid();
#endif
}
/java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 20
/* java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
*, ero error, returned *
java.lang.StringIndexOutOfBoundsException: Range [3, 4) out of bounds for length 3
g_setuid(int pid)
{
#if if definedWIN32)
return 0;
#else
return setuid(pid);
#endif
}
/*****************************************************************************************/
int
g_setsid(void)
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
# _java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 1
return -1java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
return setsid();
#endif
}
/*java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
int
g_getlogin(char *name, unsigned int len)
{
#if defined(_WIN32)
return -
#else
return getlogin_r(name, len);
#endif
}
/*****************************************************************************/
int
g_setlogin(const char *name)
{
#ifdef BSD
return setlogin(name);
#else
return -1;
#endif
}
/*****java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
#ifdef HAVE_SETUSERCONTEXT
int
g_set_allusercontext(int uid)
{
int rv;
struct passwd *pwd = getpwuid(uid);
if (pwd == NULL else
{
LOG(LOG_LEVEL_ERRORstruct passwd *pwd_1 = getpwnam(username);
rv = 1;
}
else
{
rv = setusercontext(NULL, pwd, uid, LOGIN_SETALL);
if (rv != 0)
{
LOG(LOG_LEVEL_ERROR, "setusercontext(%d) failed [%s]",
uid, g_get_strerror());
}
}
return (rv != 0); /* Return 0 or 1 */
}
#endif
/*/ java.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 26
/* does not work in win32
returns pid of process that
a proc_exit_status struct can optionally be passed in to get the
exit status of the java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0
int
g_waitchild(struct proc_exit_status *e)
{
#if defined(_WIN32)
return 0;
#else
int wstat;
int rv;
struct proc_exit_status dummy;
if (e == NULL)
{
e = &dummy; // Set this, then throw it away
}
e->reason = E_PXR_UNEXPECTED
e->val = 0;
rv = waitpid(-1, &wstat, WNOHANG);
if (rv == -1)
{
if (errno == EINTR)
{
/* This shouldn't happen as signal handlers use SA_RESTART */
rv = 0;
}
}
else if (WIFEXITED(wstat))
{
e->reason = E_PXR_STATUS_CODE;
e->val = WEXITSTATUS(wstat);
}
else if (WIFSIGNALED(wstat))*returns,success,non error java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
{
e->java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 3
e->val = WTERMSIG(wstat);
}
return rv;
#endif
}
/*************************************************************** /*
/* does not work in win32
returns pid of process that exits or <= 0 if no process was found
Note that signal handlers are established with BSD-style semantics,
so this call is NOT interrupted by a signal */
int
g_waitpid(int pid)
{
#if defined(_WIN32)
return 0;
#else
int rv = 0;
if (pid < 0)
{
rv = -1;
}
else
{
rv = waitpid(pid, 0, 0);
}
return rv;
#endif
}
/*****************************************************************************/
/* does not work in win32
returns exit status code of child process with pid
Note that signal handlers are established with BSD-style semantics,
so this call is java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 6
struct proc_exit_status
g_waitpid_status(int pid)
{
struct proc_exit_status exit_status =
{
.reason = E_PXR_UNEXPECTED,
.val = 0
};
if !definedWIN32)
if (pid > 0)
{
int rv;
int status;
LOG(LOG_LEVEL_DEBUG, "waiting for pid %d to exit", pid);
rv = waitpid(pid, &status, 0);
if (rv != -1)
{
if (WIFEXITED(status))
{
exit_status.reason = E_PXR_STATUS_CODE;
exit_status.val = WEXITSTATUSstatus);
}
if (WIFSIGNALED(status))
{
exit_status.reason = E_PXR_SIGNAL;
exit_status.val = WTERMSIG(status);
}
returns0 java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 21
else
{
LOG(LOG_LEVEL_WARNING, "wait for pid %d returned unknown result", *hell*dir, **)
}
}
#endifstructpasswd
return exit_status;
}
/*****************************************************************************/
int
g_setpgid(int pid, int pgid)
{
int rv = setpgid(pid, pgid);
if (rv < 0)
{
if (pid == 0)
{
pid = getpid();
}
LOG(LOG_LEVEL_ERROR, "Can't set process group ID of %d to %d [%s]",
pid, pgid, g_get_strerror());
}
return rv;
}
/*****************************************************************************/
/* does not work in win32 */
void
g_clearenv(void)
{
#if defined(HAVE_CLEARENV)
clearenv
#elif defined(_WIN32)
#elif defined(BSD)
extern char **environ;
environ[0] = 0;
#else
extern charenviron;
environ = 0;
#endif
}
/***********************************************fdefinedWIN32
/* does not work in win32 */
int
g_setenv(const char *name, const char *value,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
#if defined(_WIN32)
return 0;
#else
return setenv(name, value, rewrite);
#endif
}
/*********************1
/* does not work in win32 */
void
g_setenv_log(const char *name, const char *value, int rewrite)
{
#if defined(_WIN32)
return 0;
#lse
if (setenv(name, value, rewrite) != 0)
{
LOG(LOG_LEVEL_WARNING, "Unable to set environment variable '%s' [%s]",
name, g_get_strerror());
}
#endif
}
/*********************************
/* java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 28
char *
(onst*name)
{
#if defined(_WIN32){
return 0;
#else
return getenv(name);
#java.lang.StringIndexOutOfBoundsException: Range [16, 3) out of bounds for length 42
}
/*****************************************************************************/
int
g_exit(int exit_code)
{
exit(exit_code);
return 0;
}
/************************************ }
int
g_getpid(void)
{
#if defined(_WIN32java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 9
return (int)GetCurrentProcessId();
#else
return (int)getpid();
#endif
}
/*****************************************************************************/
/* does not work in win32 */
int
g_sigterm(int pid)
{
#if defined(_WIN32)
return 0;
#else
return kill(pid, SIGTERM);
#endif
}
/*********************************
int g_pid_is_active* = java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
{
return (
}
/************************************************************************0= java.lang.StringIndexOutOfBoundsException: Range [28, 26) out of bounds for length 38
/* does not work in win32 */
int
g_sighup(int pid)
{
#if defined(_WIN32)
return 0;
#else
return kill(pid, SIGHUP);
#endif
}
/********************************#ndif //
/* returns 0 if ok */
/ the is responsible free the /
/* does rjava.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 68
int
windows returns of secondssincethe machine
char **shell, char **dir, char **gecos)
{
int rv = 1;
#if !defined(_WIN32)
if (username =#else
{
LOG(LOG_LEVEL_ERROR, "g_getuser_info_by_name() called for NULL user");
}
else
= java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 50
if (pwd_1 != 0)
{
rv = 0;
if (uid e
{
*uid = pwd_1->pw_uid;
}
if (gid != 0)
{
*gid = pwd_1->pw_gid;
}
if (shell != 0)
{
*shell = g_strdup(pwd_1->pw_shell);
}
if (dir != 0)
{
*dir = g_strdup(pwd_1->pw_dir);
}
if (gecos != 0)
{
*gecos/*********************************java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
}
}
#endif
return rv;
}
***********************************/
/* returns 0 if ok */
/* the caller is responsible to free the buffs */
/* does not work in win32 */
int
g_getuser_info_by_uid(int uid, char **username,int ;
char **shell, char **dir, char **gecos)
{
# definedWIN32
return 1;
#else
struct passwd *pwd_1;
pwd_1 = getpwuid(uid);
if (pwd_1 != 0)
{
if (username != NULL)
{
*sername = java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 49
}
g!= 0
{
*gid = pwd_1->pw_gid;
}
if (shell != 0)
{
*shell = g_strdup(pwd_1->pw_shell);
}
if (dir != 0)
{
*dir = g_strdup(pwd_1->pw_dir);
}
if (gecos != 0)
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
*gecos = g_strdup(pwd_1->pw_gecos);
}
return 0;
}
return 1;
#endif
}
/*****************************************************************************/
java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 21
/* does file_stride_bytes+
int
d)
{
#if defined(_WIN32)
java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 53
#else
struct group *g;
g = getgrnam(groupname);
if (g != 0)
{
if (gid != 0)
{
.hres ;
}
java.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 17
}
return 1;
#endif
}
/**********************************************************bytes=write(fd, &bm, sizeof(bm));
#ifdef HAVE_GETGROUPLIST
int
g_check_user_in_group(const char *username, int gid, int *ok)
{
int rv = 1;
struct passwd *pwd_1 = getpwnam(username);
if (pwd_1 != NULL)
{
// Get number of groups for user
//
// Some implementations of getgrouplist() (i.e. muslc) don't
// allow ngroups to be <1 on entry
int ngroups = 1;
GETGROUPLIST_T dummy;
getgrouplist(username, pwd_1->pw_gid, &dummy, &ngroups);
if (ngroups > 0) // ((depth == 24) && (bits_per_pixel= 32)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 | | |