os: xtrans: fix calloc overflow warning
The size of `int` is machine specific and may be 64 bits wide, which could overflow the calloc'able size. Practically cannot happen here, since the ListenTransCount can't go above MAX_CONNECTIONS, but compiler can't know that and so spitting out a warning. Using uint32_t really is sufficient here. > ../os/connection.c: In function ‘CreateWellKnownSockets’: > ../os/connection.c:274:22: warning: argument 1 range [18446744071562067968, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=] > 274 | ListenTransFds = calloc(ListenTransCount, sizeof(int)); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
cc39bf7745
commit
9ddc54918a
|
@ -881,7 +881,7 @@ complete_network_count (void)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
receive_listening_fds(const char* port, XtransConnInfo* temp_ciptrs,
|
receive_listening_fds(const char* port, XtransConnInfo* temp_ciptrs,
|
||||||
int* count_ret)
|
uint32_t* count_ret)
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SYSTEMD_DAEMON
|
#ifdef HAVE_SYSTEMD_DAEMON
|
||||||
|
@ -958,7 +958,7 @@ extern int xquartz_launchd_fd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int _XSERVTransMakeAllCOTSServerListeners (const char *port, int *partial,
|
int _XSERVTransMakeAllCOTSServerListeners (const char *port, int *partial,
|
||||||
int *count_ret, XtransConnInfo **ciptrs_ret)
|
uint32_t *count_ret, XtransConnInfo **ciptrs_ret)
|
||||||
{
|
{
|
||||||
char buffer[256]; /* ??? What size ?? */
|
char buffer[256]; /* ??? What size ?? */
|
||||||
XtransConnInfo ciptr, temp_ciptrs[NUMTRANS] = { NULL };
|
XtransConnInfo ciptr, temp_ciptrs[NUMTRANS] = { NULL };
|
||||||
|
|
|
@ -50,6 +50,8 @@ from The Open Group.
|
||||||
#ifndef _XTRANS_H_
|
#ifndef _XTRANS_H_
|
||||||
#define _XTRANS_H_
|
#define _XTRANS_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <X11/Xfuncproto.h>
|
#include <X11/Xfuncproto.h>
|
||||||
#include <X11/Xos.h>
|
#include <X11/Xos.h>
|
||||||
#include <X11/Xmd.h>
|
#include <X11/Xmd.h>
|
||||||
|
@ -289,7 +291,7 @@ int _XSERVTransGetConnectionNumber (
|
||||||
int _XSERVTransMakeAllCOTSServerListeners (
|
int _XSERVTransMakeAllCOTSServerListeners (
|
||||||
const char *, /* port */
|
const char *, /* port */
|
||||||
int *, /* partial */
|
int *, /* partial */
|
||||||
int *, /* count_ret */
|
uint32_t *, /* count_ret */
|
||||||
XtransConnInfo ** /* ciptrs_ret */
|
XtransConnInfo ** /* ciptrs_ret */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ set_poll_clients(void);
|
||||||
|
|
||||||
static XtransConnInfo *ListenTransConns = NULL;
|
static XtransConnInfo *ListenTransConns = NULL;
|
||||||
static int *ListenTransFds = NULL;
|
static int *ListenTransFds = NULL;
|
||||||
static int ListenTransCount;
|
static uint32_t ListenTransCount = 0;
|
||||||
|
|
||||||
static void ErrorConnMax(XtransConnInfo /* trans_conn */ );
|
static void ErrorConnMax(XtransConnInfo /* trans_conn */ );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue