diff options
Diffstat (limited to 'lib/libX11/src')
35 files changed, 200 insertions, 339 deletions
diff --git a/lib/libX11/src/ClDisplay.c b/lib/libX11/src/ClDisplay.c index bddd7736f..aa904e516 100644 --- a/lib/libX11/src/ClDisplay.c +++ b/lib/libX11/src/ClDisplay.c @@ -65,7 +65,7 @@ XCloseDisplay ( (*ext->close_display)(dpy, &ext->codes); } /* if the closes generated more protocol, sync them up */ - if (dpy->request != dpy->last_request_read) + if (X_DPY_GET_REQUEST(dpy) != X_DPY_GET_LAST_REQUEST_READ(dpy)) XSync(dpy, 1); } xcb_disconnect(dpy->xcb->connection); diff --git a/lib/libX11/src/Font.c b/lib/libX11/src/Font.c index 650bc6f69..a73f9b19d 100644 --- a/lib/libX11/src/Font.c +++ b/lib/libX11/src/Font.c @@ -105,7 +105,7 @@ XFontStruct *XLoadQueryFont( return font_result; LockDisplay(dpy); GetReq(OpenFont, req); - seq = dpy->request; + seq = dpy->request; /* Can't use extended sequence number here */ nbytes = req->nbytes = name ? strlen(name) : 0; req->fid = fid = XAllocID(dpy); req->length += (nbytes+3)>>2; diff --git a/lib/libX11/src/FontNames.c b/lib/libX11/src/FontNames.c index 2dbca40dc..e55f338ca 100644 --- a/lib/libX11/src/FontNames.c +++ b/lib/libX11/src/FontNames.c @@ -47,7 +47,7 @@ int *actualCount) /* RETURN */ int count = 0; xListFontsReply rep; register xListFontsReq *req; - unsigned long rlen; + unsigned long rlen = 0; LockDisplay(dpy); GetReq(ListFonts, req); diff --git a/lib/libX11/src/GetAtomNm.c b/lib/libX11/src/GetAtomNm.c index 32de50d23..d7f06e365 100644 --- a/lib/libX11/src/GetAtomNm.c +++ b/lib/libX11/src/GetAtomNm.c @@ -87,8 +87,8 @@ char *XGetAtomName( } typedef struct { - unsigned long start_seq; - unsigned long stop_seq; + uint64_t start_seq; + uint64_t stop_seq; Atom *atoms; char **names; int idx; @@ -107,10 +107,11 @@ Bool _XGetAtomNameHandler( register _XGetAtomNameState *state; xGetAtomNameReply replbuf; register xGetAtomNameReply *repl; + uint64_t last_request_read = X_DPY_GET_LAST_REQUEST_READ(dpy); state = (_XGetAtomNameState *)data; - if (dpy->last_request_read < state->start_seq || - dpy->last_request_read > state->stop_seq) + if (last_request_read < state->start_seq || + last_request_read > state->stop_seq) return False; while (state->idx < state->count && state->names[state->idx]) state->idx++; @@ -152,7 +153,7 @@ XGetAtomNames ( int missed = -1; LockDisplay(dpy); - async_state.start_seq = dpy->request + 1; + async_state.start_seq = X_DPY_GET_REQUEST(dpy) + 1; async_state.atoms = atoms; async_state.names = names_return; async_state.idx = 0; @@ -165,7 +166,7 @@ XGetAtomNames ( for (i = 0; i < count; i++) { if (!(names_return[i] = _XGetAtomName(dpy, atoms[i]))) { missed = i; - async_state.stop_seq = dpy->request; + async_state.stop_seq = X_DPY_GET_REQUEST(dpy); } } if (missed >= 0) { diff --git a/lib/libX11/src/GetFPath.c b/lib/libX11/src/GetFPath.c index 62ba01436..8c3f49c95 100644 --- a/lib/libX11/src/GetFPath.c +++ b/lib/libX11/src/GetFPath.c @@ -35,7 +35,7 @@ char **XGetFontPath( int *npaths) /* RETURN */ { xGetFontPathReply rep; - unsigned long nbytes; + unsigned long nbytes = 0; char **flist = NULL; char *ch = NULL; char *chend; diff --git a/lib/libX11/src/GetWAttrs.c b/lib/libX11/src/GetWAttrs.c index c10824cf4..0f5f7bb89 100644 --- a/lib/libX11/src/GetWAttrs.c +++ b/lib/libX11/src/GetWAttrs.c @@ -30,8 +30,8 @@ in this Software without prior written authorization from The Open Group. #include "Xlibint.h" typedef struct _WAttrsState { - unsigned long attr_seq; - unsigned long geom_seq; + uint64_t attr_seq; + uint64_t geom_seq; XWindowAttributes *attr; } _XWAttrsState; @@ -47,10 +47,11 @@ _XWAttrsHandler( xGetWindowAttributesReply replbuf; register xGetWindowAttributesReply *repl; register XWindowAttributes *attr; + uint64_t last_request_read = X_DPY_GET_LAST_REQUEST_READ(dpy); state = (_XWAttrsState *)data; - if (dpy->last_request_read != state->attr_seq) { - if (dpy->last_request_read == state->geom_seq && + if (last_request_read != state->attr_seq) { + if (last_request_read == state->geom_seq && !state->attr && rep->generic.type == X_Error && rep->error.errorCode == BadDrawable) @@ -99,7 +100,7 @@ _XGetWindowAttributes( GetResReq(GetWindowAttributes, w, req); - async_state.attr_seq = dpy->request; + async_state.attr_seq = X_DPY_GET_REQUEST(dpy); async_state.geom_seq = 0; async_state.attr = attr; async.next = dpy->async_handlers; @@ -109,7 +110,7 @@ _XGetWindowAttributes( GetResReq(GetGeometry, w, req); - async_state.geom_seq = dpy->request; + async_state.geom_seq = X_DPY_GET_REQUEST(dpy); if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) { DeqAsyncHandler(dpy, &async); diff --git a/lib/libX11/src/IntAtom.c b/lib/libX11/src/IntAtom.c index 3042b65dd..d9c6c588e 100644 --- a/lib/libX11/src/IntAtom.c +++ b/lib/libX11/src/IntAtom.c @@ -188,8 +188,8 @@ XInternAtom ( } typedef struct { - unsigned long start_seq; - unsigned long stop_seq; + uint64_t start_seq; + uint64_t stop_seq; char **names; Atom *atoms; int count; @@ -208,10 +208,12 @@ Bool _XIntAtomHandler( register int i, idx = 0; xInternAtomReply replbuf; register xInternAtomReply *repl; + uint64_t last_request_read = X_DPY_GET_LAST_REQUEST_READ(dpy); state = (_XIntAtomState *)data; - if (dpy->last_request_read < state->start_seq || - dpy->last_request_read > state->stop_seq) + + if (last_request_read < state->start_seq || + last_request_read > state->stop_seq) return False; for (i = 0; i < state->count; i++) { if (state->atoms[i] & 0x80000000) { @@ -252,7 +254,7 @@ XInternAtoms ( xInternAtomReply rep; LockDisplay(dpy); - async_state.start_seq = dpy->request + 1; + async_state.start_seq = X_DPY_GET_REQUEST(dpy) + 1; async_state.atoms = atoms_return; async_state.names = names; async_state.count = count - 1; @@ -266,7 +268,7 @@ XInternAtoms ( &sig, &idx, &n))) { missed = i; atoms_return[i] = ~((Atom)idx); - async_state.stop_seq = dpy->request; + async_state.stop_seq = X_DPY_GET_REQUEST(dpy); } } if (missed >= 0) { diff --git a/lib/libX11/src/ListExt.c b/lib/libX11/src/ListExt.c index 75f5f5428..0516e4596 100644 --- a/lib/libX11/src/ListExt.c +++ b/lib/libX11/src/ListExt.c @@ -42,7 +42,7 @@ char **XListExtensions( register unsigned i; register int length; register xReq *req; - unsigned long rlen; + unsigned long rlen = 0; LockDisplay(dpy); GetEmptyReq (ListExtensions, req); diff --git a/lib/libX11/src/Makefile.am b/lib/libX11/src/Makefile.am index 762acd75e..f8c476de9 100644 --- a/lib/libX11/src/Makefile.am +++ b/lib/libX11/src/Makefile.am @@ -346,7 +346,6 @@ EXTRA_DIST = \ libX11_xcb_la_SOURCES = x11_xcb.c Xxcbint.h libX11_xcb_la_LDFLAGS = -version-number 1:0:0 -no-undefined -libX11_xcb_la_LIBADD = libX11.la # # Figure out which sub-libraries to link into Xlib diff --git a/lib/libX11/src/Makefile.in b/lib/libX11/src/Makefile.in index f0facaed4..6a652d78a 100644 --- a/lib/libX11/src/Makefile.in +++ b/lib/libX11/src/Makefile.in @@ -102,7 +102,7 @@ am__uninstall_files_from_dir = { \ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(lintlibdir)" \ "$(DESTDIR)$(x11datadir)" LTLIBRARIES = $(lib_LTLIBRARIES) -libX11_xcb_la_DEPENDENCIES = libX11.la +libX11_xcb_la_LIBADD = am_libX11_xcb_la_OBJECTS = x11_xcb.lo libX11_xcb_la_OBJECTS = $(am_libX11_xcb_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) @@ -599,7 +599,6 @@ EXTRA_DIST = \ libX11_xcb_la_SOURCES = x11_xcb.c Xxcbint.h libX11_xcb_la_LDFLAGS = -version-number 1:0:0 -no-undefined -libX11_xcb_la_LIBADD = libX11.la # # Figure out which sub-libraries to link into Xlib diff --git a/lib/libX11/src/OpenDis.c b/lib/libX11/src/OpenDis.c index 636860e24..82723578e 100644 --- a/lib/libX11/src/OpenDis.c +++ b/lib/libX11/src/OpenDis.c @@ -197,8 +197,8 @@ XOpenDisplay ( dpy->idlist_alloc = _XAllocIDs; dpy->synchandler = NULL; dpy->savedsynchandler = NULL; - dpy->request = 0; - dpy->last_request_read = 0; + X_DPY_SET_REQUEST(dpy, 0); + X_DPY_SET_LAST_REQUEST_READ(dpy, 0); dpy->default_screen = iscreen; /* Value returned by ConnectDisplay */ dpy->last_req = (char *)&_dummy_request; diff --git a/lib/libX11/src/PutImage.c b/lib/libX11/src/PutImage.c index de085bcde..13cbba356 100644 --- a/lib/libX11/src/PutImage.c +++ b/lib/libX11/src/PutImage.c @@ -602,7 +602,7 @@ static int const HalfOrderWord[12] = { #define UnGetReq(name)\ dpy->bufptr -= SIZEOF(x##name##Req);\ - dpy->request-- + X_DPY_REQUEST_DECREMENT(dpy) static void SendXYImage( diff --git a/lib/libX11/src/XlibAsync.c b/lib/libX11/src/XlibAsync.c index eb2b81963..d62000e54 100644 --- a/lib/libX11/src/XlibAsync.c +++ b/lib/libX11/src/XlibAsync.c @@ -32,6 +32,18 @@ from The Open Group. #include <X11/Xlibint.h> #include <X11/Xos.h> +/* + * Xlib's _XAsyncErrorState sequence number may wrap in 32bit + * and we cannot use 64bit as it's public API. + */ +#ifdef LONG64 +#define _XLIB_ASYNC_SEQUENCE_CMP(a,op,b) ((a == 0) || (a op b)) +#else /* !LONG64 */ +#define _XLIB_ASYNC_SEQUENCE_CMP(a,op,b) ((a == 0) || \ + (((a op b) && (b - a op (UINT32_MAX >> 1))) || \ + ((b op a) && ((UINT32_MAX >> 1) op a - b)))) +#endif /* !LONG64 */ + /*ARGSUSED*/ Bool _XAsyncErrorHandler( @@ -51,10 +63,8 @@ _XAsyncErrorHandler( rep->error.majorCode == state->major_opcode) && (!state->minor_opcode || rep->error.minorCode == state->minor_opcode) && - (!state->min_sequence_number || - (state->min_sequence_number <= dpy->last_request_read)) && - (!state->max_sequence_number || - (state->max_sequence_number >= dpy->last_request_read))) { + (_XLIB_ASYNC_SEQUENCE_CMP(state->min_sequence_number,<=,dpy->last_request_read)) && + (_XLIB_ASYNC_SEQUENCE_CMP(state->max_sequence_number,>=,dpy->last_request_read))) { state->last_error_received = rep->error.errorCode; state->error_count++; return True; diff --git a/lib/libX11/src/XlibInt.c b/lib/libX11/src/XlibInt.c index 80c12987d..729694885 100644 --- a/lib/libX11/src/XlibInt.c +++ b/lib/libX11/src/XlibInt.c @@ -167,8 +167,12 @@ void _XPollfdCacheDel( static int sync_hazard(Display *dpy) { - unsigned long span = dpy->request - dpy->last_request_read; - unsigned long hazard = min((dpy->bufmax - dpy->buffer) / SIZEOF(xReq), 65535 - 10); + /* + * "span" and "hazard" need to be signed such that the ">=" comparision + * works correctly in the case that hazard is greater than 65525 + */ + int64_t span = X_DPY_GET_REQUEST(dpy) - X_DPY_GET_LAST_REQUEST_READ(dpy); + int64_t hazard = min((dpy->bufmax - dpy->buffer) / SIZEOF(xReq), 65535 - 10); return span >= 65535 - hazard - 10; } @@ -194,7 +198,7 @@ void _XSeqSyncFunction( xGetInputFocusReply rep; register xReq *req; - if ((dpy->request - dpy->last_request_read) >= (65535 - BUFSIZE/SIZEOF(xReq))) { + if ((X_DPY_GET_REQUEST(dpy) - X_DPY_GET_LAST_REQUEST_READ(dpy)) >= (65535 - BUFSIZE/SIZEOF(xReq))) { GetEmptyReq(GetInputFocus, req); (void) _XReply (dpy, (xReply *)&rep, 0, xTrue); sync_while_locked(dpy); @@ -276,9 +280,9 @@ _XSetLastRequestRead( register Display *dpy, register xGenericReply *rep) { - register unsigned long newseq, lastseq; + register uint64_t newseq, lastseq; - lastseq = dpy->last_request_read; + lastseq = X_DPY_GET_LAST_REQUEST_READ(dpy); /* * KeymapNotify has no sequence number, but is always guaranteed * to immediately follow another event, except when generated via @@ -287,20 +291,21 @@ _XSetLastRequestRead( if ((rep->type & 0x7f) == KeymapNotify) return(lastseq); - newseq = (lastseq & ~((unsigned long)0xffff)) | rep->sequenceNumber; + newseq = (lastseq & ~((uint64_t)0xffff)) | rep->sequenceNumber; if (newseq < lastseq) { newseq += 0x10000; - if (newseq > dpy->request) { + if (newseq > X_DPY_GET_REQUEST(dpy)) { (void) fprintf (stderr, - "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n", - newseq, dpy->request, + "Xlib: sequence lost (0x%llx > 0x%llx) in reply type 0x%x!\n", + (unsigned long long)newseq, + (unsigned long long)(X_DPY_GET_REQUEST(dpy)), (unsigned int) rep->type); newseq -= 0x10000; } } - dpy->last_request_read = newseq; + X_DPY_SET_LAST_REQUEST_READ(dpy, newseq); return(newseq); } @@ -1256,7 +1261,7 @@ int _XDefaultIOError( } exit(1); - return(0); /* dummy - function should never return */ + /*NOTREACHED*/ } @@ -1363,10 +1368,10 @@ static int _XPrintDefaultError( mesg, BUFSIZ); fputs(" ", fp); (void) fprintf(fp, mesg, event->serial); - XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d", + XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%lld", mesg, BUFSIZ); fputs("\n ", fp); - (void) fprintf(fp, mesg, dpy->request); + (void) fprintf(fp, mesg, (unsigned long long)(X_DPY_GET_REQUEST(dpy))); fputs("\n", fp); if (event->error_code == BadImplementation) return 0; return 1; @@ -1465,7 +1470,7 @@ _XIOError ( else _XDefaultIOError(dpy); exit (1); - return 0; + /*NOTREACHED*/ } @@ -1720,7 +1725,7 @@ void *_XGetRequest(Display *dpy, CARD8 type, size_t len) req->reqType = type; req->length = len / 4; dpy->bufptr += len; - dpy->request++; + X_DPY_REQUEST_INCREMENT(dpy); return req; } diff --git a/lib/libX11/src/Xxcbint.h b/lib/libX11/src/Xxcbint.h index bf41c23ff..4ef13d2ff 100644 --- a/lib/libX11/src/Xxcbint.h +++ b/lib/libX11/src/Xxcbint.h @@ -13,12 +13,12 @@ #include <X11/Xlib-xcb.h> #include "locking.h" -#define XLIB_SEQUENCE_COMPARE(a,op,b) (((long) (a) - (long) (b)) op 0) +#define XLIB_SEQUENCE_COMPARE(a,op,b) (((int64_t) (a) - (int64_t) (b)) op 0) typedef struct PendingRequest PendingRequest; struct PendingRequest { PendingRequest *next; - unsigned long sequence; + uint64_t sequence; unsigned reply_waiter; }; @@ -46,6 +46,7 @@ typedef struct _X11XCBPrivate { int _XConnectXCB(Display *dpy, _Xconst char *display, int *screenp); void _XFreeX11XCBStructure(Display *dpy); +_X_HIDDEN unsigned long _XNextRequest(Display *dpy); #endif /* XXCBINT_H */ diff --git a/lib/libX11/src/config.h.in b/lib/libX11/src/config.h.in index 96a72d8be..e3738bb8f 100644 --- a/lib/libX11/src/config.h.in +++ b/lib/libX11/src/config.h.in @@ -15,12 +15,6 @@ /* Has shm*() functions */ #undef HAS_SHM -/* Define to 1 if you have the `authdes_create' function. */ -#undef HAVE_AUTHDES_CREATE - -/* Define to 1 if you have the `authdes_seccreate' function. */ -#undef HAVE_AUTHDES_SECCREATE - /* Define to 1 if you have the <dlfcn.h> header file. */ #undef HAVE_DLFCN_H @@ -93,9 +87,6 @@ /* Support os-specific local connections */ #undef LOCALCONN -/* preference sorted list of transport types to try for local connections */ -#undef LOCAL_TRANSPORT_LIST - /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR @@ -133,9 +124,6 @@ /* Patch version of this package */ #undef PACKAGE_VERSION_PATCHLEVEL -/* Support Secure RPC ("SUN-DES-1") authentication for X11 clients */ -#undef SECURE_RPC - /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS diff --git a/lib/libX11/src/xcb_io.c b/lib/libX11/src/xcb_io.c index 59873296c..bd26a62ae 100644 --- a/lib/libX11/src/xcb_io.c +++ b/lib/libX11/src/xcb_io.c @@ -68,22 +68,8 @@ static void require_socket(Display *dpy) if(!xcb_take_socket(dpy->xcb->connection, return_socket, dpy, flags, &sent)) _XIOError(dpy); - /* Xlib uses unsigned long for sequence numbers. XCB - * uses 64-bit internally, but currently exposes an - * unsigned int API. If these differ, Xlib cannot track - * the full 64-bit sequence number if 32-bit wrap - * happens while Xlib does not own the socket. A - * complete fix would be to make XCB's public API use - * 64-bit sequence numbers. */ - if (sizeof(unsigned long) > sizeof(unsigned int) && - dpy->xcb->event_owner == XlibOwnsEventQueue && - (sent - dpy->last_request_read >= (UINT64_C(1) << 32))) { - throw_thread_fail_assert("Sequence number wrapped " - "beyond 32 bits while Xlib " - "did not own the socket", - xcb_xlib_seq_number_wrapped); - } - dpy->xcb->last_flushed = dpy->request = sent; + dpy->xcb->last_flushed = sent; + X_DPY_SET_REQUEST(dpy, sent); dpy->bufmax = dpy->xcb->real_bufmax; } } @@ -145,7 +131,7 @@ static void check_internal_connections(Display *dpy) } } -static PendingRequest *append_pending_request(Display *dpy, unsigned long sequence) +static PendingRequest *append_pending_request(Display *dpy, uint64_t sequence) { PendingRequest *node = malloc(sizeof(PendingRequest)); assert(node); @@ -214,14 +200,13 @@ static int handle_error(Display *dpy, xError *err, Bool in_XReply) return 0; } -/* Widen a 32-bit sequence number into a native-word-size (unsigned long) - * sequence number. Treating the comparison as a 1 and shifting it avoids a - * conditional branch, and shifting by 16 twice avoids a compiler warning when - * sizeof(unsigned long) == 4. */ -static void widen(unsigned long *wide, unsigned int narrow) +/* Widen a 32-bit sequence number into a 64bit (uint64_t) sequence number. + * Treating the comparison as a 1 and shifting it avoids a conditional branch. + */ +static void widen(uint64_t *wide, unsigned int narrow) { - unsigned long new = (*wide & ~0xFFFFFFFFUL) | narrow; - *wide = new + ((unsigned long) (new < *wide) << 16 << 16); + uint64_t new = (*wide & ~((uint64_t)0xFFFFFFFFUL)) | narrow; + *wide = new + (((uint64_t)(new < *wide)) << 32); } /* Thread-safety rules: @@ -260,20 +245,20 @@ static xcb_generic_reply_t *poll_for_event(Display *dpy) { PendingRequest *req = dpy->xcb->pending_requests; xcb_generic_event_t *event = dpy->xcb->next_event; - unsigned long event_sequence = dpy->last_request_read; + uint64_t event_sequence = X_DPY_GET_LAST_REQUEST_READ(dpy); widen(&event_sequence, event->full_sequence); if(!req || XLIB_SEQUENCE_COMPARE(event_sequence, <, req->sequence) || (event->response_type != X_Error && event_sequence == req->sequence)) { - if (XLIB_SEQUENCE_COMPARE(event_sequence, >, - dpy->request)) + uint64_t request = X_DPY_GET_REQUEST(dpy); + if (XLIB_SEQUENCE_COMPARE(event_sequence, >, request)) { throw_thread_fail_assert("Unknown sequence " "number while " "processing queue", xcb_xlib_threads_sequence_lost); } - dpy->last_request_read = event_sequence; + X_DPY_SET_LAST_REQUEST_READ(dpy, event_sequence); dpy->xcb->next_event = NULL; return (xcb_generic_reply_t *) event; } @@ -289,15 +274,16 @@ static xcb_generic_reply_t *poll_for_response(Display *dpy) while(!(response = poll_for_event(dpy)) && (req = dpy->xcb->pending_requests) && !req->reply_waiter && - xcb_poll_for_reply(dpy->xcb->connection, req->sequence, &response, &error)) + xcb_poll_for_reply64(dpy->xcb->connection, req->sequence, &response, &error)) { - if(XLIB_SEQUENCE_COMPARE(req->sequence, >, dpy->request)) + uint64_t request = X_DPY_GET_REQUEST(dpy); + if(XLIB_SEQUENCE_COMPARE(req->sequence, >, request)) { throw_thread_fail_assert("Unknown sequence number " "while awaiting reply", xcb_xlib_threads_sequence_lost); } - dpy->last_request_read = req->sequence; + X_DPY_SET_LAST_REQUEST_READ(dpy, req->sequence); if(response) break; dequeue_pending_request(dpy, req); @@ -456,6 +442,7 @@ void _XSend(Display *dpy, const char *data, long size) static char const pad[3]; struct iovec vec[3]; uint64_t requests; + uint64_t dpy_request; _XExtension *ext; xcb_connection_t *c = dpy->xcb->connection; if(dpy->flags & XlibDisplayIOError) @@ -464,6 +451,10 @@ void _XSend(Display *dpy, const char *data, long size) if(dpy->bufptr == dpy->buffer && !size) return; + /* append_pending_request does not alter the dpy request number + * therefore we can get it outside of the loop and the if + */ + dpy_request = X_DPY_GET_REQUEST(dpy); /* iff we asked XCB to set aside errors, we must pick those up * eventually. iff there are async handlers, we may have just * issued requests that will generate replies. in either case, @@ -471,11 +462,11 @@ void _XSend(Display *dpy, const char *data, long size) if(dpy->xcb->event_owner != XlibOwnsEventQueue || dpy->async_handlers) { uint64_t sequence; - for(sequence = dpy->xcb->last_flushed + 1; sequence <= dpy->request; ++sequence) + for(sequence = dpy->xcb->last_flushed + 1; sequence <= dpy_request; ++sequence) append_pending_request(dpy, sequence); } - requests = dpy->request - dpy->xcb->last_flushed; - dpy->xcb->last_flushed = dpy->request; + requests = dpy_request - dpy->xcb->last_flushed; + dpy->xcb->last_flushed = dpy_request; vec[0].iov_base = dpy->buffer; vec[0].iov_len = dpy->bufptr - dpy->buffer; @@ -570,6 +561,7 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard) xcb_connection_t *c = dpy->xcb->connection; char *reply; PendingRequest *current; + uint64_t dpy_request; if (dpy->xcb->reply_data) throw_extlib_fail_assert("Extra reply data still left in queue", @@ -579,10 +571,12 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard) return 0; _XSend(dpy, NULL, 0); - if(dpy->xcb->pending_requests_tail && dpy->xcb->pending_requests_tail->sequence == dpy->request) + dpy_request = X_DPY_GET_REQUEST(dpy); + if(dpy->xcb->pending_requests_tail + && dpy->xcb->pending_requests_tail->sequence == dpy_request) current = dpy->xcb->pending_requests_tail; else - current = append_pending_request(dpy, dpy->request); + current = append_pending_request(dpy, dpy_request); /* Don't let any other thread get this reply. */ current->reply_waiter = 1; @@ -599,9 +593,9 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard) } req->reply_waiter = 1; UnlockDisplay(dpy); - response = xcb_wait_for_reply(c, req->sequence, &error); + response = xcb_wait_for_reply64(c, req->sequence, &error); /* Any user locks on another thread must have been taken - * while we slept in xcb_wait_for_reply. Classic Xlib + * while we slept in xcb_wait_for_reply64. Classic Xlib * ignored those user locks in this case, so we do too. */ InternalLockDisplay(dpy, /* ignore user locks */ 1); @@ -629,12 +623,13 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard) req->reply_waiter = 0; ConditionBroadcast(dpy, dpy->xcb->reply_notify); - if(XLIB_SEQUENCE_COMPARE(req->sequence, >, dpy->request)) { + dpy_request = X_DPY_GET_REQUEST(dpy); + if(XLIB_SEQUENCE_COMPARE(req->sequence, >, dpy_request)) { throw_thread_fail_assert("Unknown sequence number " "while processing reply", xcb_xlib_threads_sequence_lost); } - dpy->last_request_read = req->sequence; + X_DPY_SET_LAST_REQUEST_READ(dpy, req->sequence); if(!response) dequeue_pending_request(dpy, req); @@ -654,9 +649,10 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard) if(dpy->xcb->next_event && dpy->xcb->next_event->response_type == X_Error) { xcb_generic_event_t *event = dpy->xcb->next_event; - unsigned long event_sequence = dpy->last_request_read; + uint64_t last_request_read = X_DPY_GET_LAST_REQUEST_READ(dpy); + uint64_t event_sequence = last_request_read; widen(&event_sequence, event->full_sequence); - if(event_sequence == dpy->last_request_read) + if(event_sequence == last_request_read) { error = (xcb_generic_error_t *) event; dpy->xcb->next_event = NULL; diff --git a/lib/libX11/src/xcms/HVC.c b/lib/libX11/src/xcms/HVC.c index 80f1735cf..ce02ab3af 100644 --- a/lib/libX11/src/xcms/HVC.c +++ b/lib/libX11/src/xcms/HVC.c @@ -176,13 +176,13 @@ TekHVC_ParseString( * XcmsSuccess if valid. */ { - int n; + size_t n; char *pchar; if ((pchar = strchr(spec, ':')) == NULL) { return(XcmsFailure); } - n = (int)(pchar - spec); + n = (size_t)(pchar - spec); /* * Check for proper prefix. @@ -349,7 +349,7 @@ XcmsTekHVCToCIEuvY( XcmsCIEuvY uvY_return; XcmsFloat tempHue, u, v; XcmsFloat tmpVal; - register int i; + unsigned int i; /* * Check arguments @@ -468,7 +468,7 @@ XcmsCIEuvYToTekHVC( XcmsColor *pColor = pColors_in_out; XcmsColor whitePt; XcmsTekHVC HVC_return; - register int i; + unsigned int i; /* * Check arguments diff --git a/lib/libX11/src/xcms/IdOfPr.c b/lib/libX11/src/xcms/IdOfPr.c index e15f34fec..9f43dd387 100644 --- a/lib/libX11/src/xcms/IdOfPr.c +++ b/lib/libX11/src/xcms/IdOfPr.c @@ -61,7 +61,7 @@ XcmsFormatOfPrefix(char *prefix) XcmsColorSpace **papColorSpaces; char string_buf[64]; char *string_lowered; - int len; + size_t len; /* * While copying prefix to string_lowered, convert to lowercase diff --git a/lib/libX11/src/xcms/LRGB.c b/lib/libX11/src/xcms/LRGB.c index 461d07d87..380b4d17d 100644 --- a/lib/libX11/src/xcms/LRGB.c +++ b/lib/libX11/src/xcms/LRGB.c @@ -966,7 +966,7 @@ _XcmsGetTableType1( * */ { - int count; + unsigned int count; unsigned int max_index; IntensityRec *pIRec; @@ -1405,13 +1405,13 @@ XcmsLRGB_RGBi_ParseString( * 0 if failed, non-zero otherwise. */ { - int n; + size_t n; char *pchar; if ((pchar = strchr(spec, ':')) == NULL) { return(XcmsFailure); } - n = (int)(pchar - spec); + n = (size_t)(pchar - spec); /* * Check for proper prefix. diff --git a/lib/libX11/src/xcms/Lab.c b/lib/libX11/src/xcms/Lab.c index 02c8d3b7c..bf6ae54db 100644 --- a/lib/libX11/src/xcms/Lab.c +++ b/lib/libX11/src/xcms/Lab.c @@ -251,7 +251,7 @@ XcmsCIELabToCIEXYZ( XcmsCIEXYZ XYZ_return; XcmsFloat tmpFloat, tmpL; XcmsColor whitePt; - int i; + unsigned int i; XcmsColor *pColor = pColors_in_out; /* @@ -354,7 +354,7 @@ XcmsCIEXYZToCIELab( XcmsCIELab Lab_return; XcmsFloat fX_Xn, fY_Yn, fZ_Zn; XcmsColor whitePt; - int i; + unsigned int i; XcmsColor *pColor = pColors_in_out; /* diff --git a/lib/libX11/src/xcms/Luv.c b/lib/libX11/src/xcms/Luv.c index 82bc2946a..c27018a73 100644 --- a/lib/libX11/src/xcms/Luv.c +++ b/lib/libX11/src/xcms/Luv.c @@ -251,7 +251,7 @@ XcmsCIELuvToCIEuvY( XcmsColor whitePt; XcmsCIEuvY uvY_return; XcmsFloat tmpVal; - register int i; + unsigned int i; /* * Check arguments @@ -343,7 +343,7 @@ XcmsCIEuvYToCIELuv( XcmsColor whitePt; XcmsCIELuv Luv_return; XcmsFloat tmpVal; - register int i; + unsigned int i; /* * Check arguments diff --git a/lib/libX11/src/xcms/XYZ.c b/lib/libX11/src/xcms/XYZ.c index 40d6ed3bb..0544b6ab6 100644 --- a/lib/libX11/src/xcms/XYZ.c +++ b/lib/libX11/src/xcms/XYZ.c @@ -120,13 +120,13 @@ CIEXYZ_ParseString( * RETURNS */ { - int n; + size_t n; char *pchar; if ((pchar = strchr(spec, ':')) == NULL) { return(XcmsFailure); } - n = (int)(pchar - spec); + n = (size_t)(pchar - spec); /* * Check for proper prefix. diff --git a/lib/libX11/src/xcms/cmsColNm.c b/lib/libX11/src/xcms/cmsColNm.c index ab6e4e879..020aa4d11 100644 --- a/lib/libX11/src/xcms/cmsColNm.c +++ b/lib/libX11/src/xcms/cmsColNm.c @@ -126,13 +126,13 @@ _XcmsColorSpaceOfString( */ { XcmsColorSpace **papColorSpaces; - int n; + size_t n; char *pchar; if ((pchar = strchr(color_string, ':')) == NULL) { return(XcmsFailure); } - n = (int)(pchar - color_string); + n = (size_t)(pchar - color_string); if (ccc == NULL) { return(NULL); @@ -198,7 +198,7 @@ _XcmsParseColorString( XcmsColorSpace *pColorSpace; char string_buf[64]; char *string_lowered; - int len; + size_t len; int res; if (ccc == NULL) { diff --git a/lib/libX11/src/xcms/cmsTrig.c b/lib/libX11/src/xcms/cmsTrig.c index fc65d9ba3..ebb92be5b 100644 --- a/lib/libX11/src/xcms/cmsTrig.c +++ b/lib/libX11/src/xcms/cmsTrig.c @@ -379,21 +379,10 @@ static double _XcmsPolynomial( { auto double rtn_value; -#if 0 - auto double curr_coeff; - if (order <= 0) { - rtn_value = *coeffs; - } else { - curr_coeff = *coeffs; /* Bug in Unisoft's compiler. Does not */ - coeffs++; /* generate good code for *coeffs++ */ - rtn_value = curr_coeff + x * _XcmsPolynomial (--order, coeffs, x); - } -#else /* ++jrb -- removed tail recursion */ coeffs += order; rtn_value = *coeffs--; while(order-- > 0) rtn_value = *coeffs-- + (x * rtn_value); -#endif return(rtn_value); } diff --git a/lib/libX11/src/xcms/uvY.c b/lib/libX11/src/xcms/uvY.c index 5344fb17c..9f0ad2b5c 100644 --- a/lib/libX11/src/xcms/uvY.c +++ b/lib/libX11/src/xcms/uvY.c @@ -135,13 +135,13 @@ CIEuvY_ParseString( * 0 if failed, non-zero otherwise. */ { - int n; + size_t n; char *pchar; if ((pchar = strchr(spec, ':')) == NULL) { return(XcmsFailure); } - n = (int)(pchar - spec); + n = (size_t)(pchar - spec); /* * Check for proper prefix. @@ -243,7 +243,7 @@ XcmsCIEuvYToCIEXYZ( { XcmsCIEXYZ XYZ_return; XcmsColor whitePt; - int i; + unsigned int i; XcmsColor *pColor = pColors_in_out; XcmsFloat div, x, y, z, Y; @@ -358,7 +358,7 @@ XcmsCIEXYZToCIEuvY( { XcmsCIEuvY uvY_return; XcmsColor whitePt; - int i; + unsigned int i; XcmsColor *pColor = pColors_in_out; XcmsFloat div; diff --git a/lib/libX11/src/xcms/xyY.c b/lib/libX11/src/xcms/xyY.c index 6f9457496..88206c355 100644 --- a/lib/libX11/src/xcms/xyY.c +++ b/lib/libX11/src/xcms/xyY.c @@ -253,7 +253,7 @@ XcmsCIExyYToCIEXYZ( XcmsCIEXYZ XYZ_return; XcmsFloat div; /* temporary storage in case divisor is zero */ XcmsFloat u, v, x, y, z; /* temporary storage */ - register int i; + unsigned int i; /* * Check arguments @@ -359,7 +359,7 @@ XcmsCIEXYZToCIExyY( XcmsColor *pColor = pColors_in_out; XcmsCIExyY xyY_return; XcmsFloat div; /* temporary storage in case divisor is zero */ - register int i; + unsigned int i; /* * Check arguments diff --git a/lib/libX11/src/xkb/XKBGetByName.c b/lib/libX11/src/xkb/XKBGetByName.c index 973052ce6..362761cd3 100644 --- a/lib/libX11/src/xkb/XKBGetByName.c +++ b/lib/libX11/src/xkb/XKBGetByName.c @@ -44,7 +44,7 @@ XkbGetKeyboardByName(Display *dpy, { register xkbGetKbdByNameReq *req; xkbGetKbdByNameReply rep; - int len, extraLen; + int len, extraLen = 0; char *str; XkbDescPtr xkb; int mapLen, codesLen, typesLen, compatLen; @@ -204,12 +204,16 @@ XkbGetKeyboardByName(Display *dpy, if (status != Success) goto BAILOUT; } + if (extraLen > 0) + goto BAILOUT; UnlockDisplay(dpy); SyncHandle(); return xkb; BAILOUT: if (xkb != NULL) XkbFreeKeyboard(xkb, XkbAllComponentsMask, xTrue); + if (extraLen > 0) + _XEatData(dpy, extraLen); UnlockDisplay(dpy); SyncHandle(); return NULL; diff --git a/lib/libX11/src/xkb/XKBNames.c b/lib/libX11/src/xkb/XKBNames.c index 6c4800c29..d84f34b55 100644 --- a/lib/libX11/src/xkb/XKBNames.c +++ b/lib/libX11/src/xkb/XKBNames.c @@ -549,7 +549,7 @@ XkbChangeNames(Display *dpy, XkbDescPtr xkb, XkbNameChangesPtr changes) which = changes->changed; firstType = changes->first_type; nTypes = changes->num_types; - firstLvlType = changes->first_lvl;; + firstLvlType = changes->first_lvl; nLvlTypes = changes->num_lvls; if (which & XkbKeyTypeNamesMask) { if (nTypes < 1) diff --git a/lib/libX11/src/xlibi18n/ICWrap.c b/lib/libX11/src/xlibi18n/ICWrap.c index 8c1b4a01c..69f080d87 100644 --- a/lib/libX11/src/xlibi18n/ICWrap.c +++ b/lib/libX11/src/xlibi18n/ICWrap.c @@ -169,7 +169,7 @@ XSetIMValues(XIM im, ...) va_list var; int total_count; XIMArg *args; - char *ret; + char *ret = NULL; /* * so count the stuff dangling here @@ -185,7 +185,8 @@ XSetIMValues(XIM im, ...) _XIMVaToNestedList(var, total_count, &args); va_end(var); - ret = (*im->methods->set_values) (im, args); + if (im && im->methods) + ret = (*im->methods->set_values) (im, args); Xfree(args); return ret; } @@ -196,7 +197,7 @@ XGetIMValues(XIM im, ...) va_list var; int total_count; XIMArg *args; - char *ret; + char *ret = NULL; /* * so count the stuff dangling here @@ -212,7 +213,8 @@ XGetIMValues(XIM im, ...) _XIMVaToNestedList(var, total_count, &args); va_end(var); - ret = (*im->methods->get_values) (im, args); + if (im && im->methods) + ret = (*im->methods->get_values) (im, args); Xfree(args); return ret; } @@ -228,7 +230,7 @@ XCreateIC(XIM im, ...) va_list var; int total_count; XIMArg *args; - XIC ic; + XIC ic = NULL; /* * so count the stuff dangling here @@ -244,7 +246,8 @@ XCreateIC(XIM im, ...) _XIMVaToNestedList(var, total_count, &args); va_end(var); - ic = (XIC) (*im->methods->create_ic) (im, args); + if (im && im->methods) + ic = (XIC) (*im->methods->create_ic) (im, args); Xfree(args); if (ic) { ic->core.next = im->core.ic_chain; diff --git a/lib/libX11/src/xlibi18n/XDefaultIMIF.c b/lib/libX11/src/xlibi18n/XDefaultIMIF.c index db0f5d1fa..7c32ce296 100644 --- a/lib/libX11/src/xlibi18n/XDefaultIMIF.c +++ b/lib/libX11/src/xlibi18n/XDefaultIMIF.c @@ -168,32 +168,25 @@ _XDefaultOpenIM( char *res_class) { StaticXIM im; - XIMStaticXIMRec *local_impart; - XlcConv ctom_conv, ctow_conv; int i; char *mod; char buf[BUFSIZ]; - if (!(ctom_conv = _XlcOpenConverter(lcd, - XlcNCompoundText, lcd, XlcNMultiByte))) { - return((XIM)NULL); - } + if ((im = Xcalloc(1, sizeof(StaticXIMRec))) == NULL) + return NULL; - if (!(ctow_conv = _XlcOpenConverter(lcd, - XlcNCompoundText, lcd, XlcNWideChar))) { - return((XIM)NULL); - } + if ((im->private = Xcalloc(1, sizeof(XIMStaticXIMRec))) == NULL) + goto Error; - if ((im = Xmalloc(sizeof(StaticXIMRec))) == (StaticXIM)NULL) { - return((XIM)NULL); - } - if ((local_impart = Xmalloc(sizeof(XIMStaticXIMRec))) - == (XIMStaticXIMRec *)NULL) { - Xfree(im); - return((XIM)NULL); - } - memset(im, 0, sizeof(StaticXIMRec)); - memset(local_impart, 0, sizeof(XIMStaticXIMRec)); + if ((im->private->ctom_conv = _XlcOpenConverter(lcd, XlcNCompoundText, + lcd, XlcNMultiByte)) + == NULL) + goto Error; + + if ((im->private->ctow_conv = _XlcOpenConverter(lcd, XlcNCompoundText, + lcd, XlcNWideChar)) + == NULL) + goto Error; buf[0] = '\0'; i = 0; @@ -209,11 +202,9 @@ _XDefaultOpenIM( } } #undef MODIFIER - if ((im->core.im_name = Xmalloc(i+1)) == NULL) - goto Error2; - strcpy(im->core.im_name, buf); + if ((im->core.im_name = strdup(buf)) == NULL) + goto Error; - im->private = local_impart; im->methods = (XIMMethods)&local_im_methods; im->core.lcd = lcd; im->core.ic_chain = (XIC)NULL; @@ -222,9 +213,6 @@ _XDefaultOpenIM( im->core.res_name = NULL; im->core.res_class = NULL; - local_impart->ctom_conv = ctom_conv; - local_impart->ctow_conv = ctow_conv; - if ((res_name != NULL) && (*res_name != '\0')){ im->core.res_name = strdup(res_name); } @@ -233,12 +221,10 @@ _XDefaultOpenIM( } return (XIM)im; -Error2 : - Xfree(im->private); - Xfree(im->core.im_name); + + Error: + _CloseIM((XIM)im); Xfree(im); - _XlcCloseConverter(ctom_conv); - _XlcCloseConverter(ctow_conv); return(NULL); } @@ -246,13 +232,16 @@ static Status _CloseIM(XIM xim) { StaticXIM im = (StaticXIM)xim; - _XlcCloseConverter(im->private->ctom_conv); - _XlcCloseConverter(im->private->ctow_conv); + + if (im->private->ctom_conv != NULL) + _XlcCloseConverter(im->private->ctom_conv); + if (im->private->ctow_conv != NULL) + _XlcCloseConverter(im->private->ctow_conv); XFree(im->private); XFree(im->core.im_name); - if (im->core.res_name) XFree(im->core.res_name); - if (im->core.res_class) XFree(im->core.res_class); - return 1; /*bugID 4163122*/ + XFree(im->core.res_name); + XFree(im->core.res_class); + return 1; } static char * @@ -344,10 +333,9 @@ _CreateIC(XIM im, XIMArg *arg) { XIC ic; - if ((ic = Xmalloc(sizeof(XICRec))) == (XIC)NULL) { + if ((ic = Xcalloc(1, sizeof(XICRec))) == (XIC)NULL) { return ((XIC)NULL); } - memset(ic, 0, sizeof(XICRec)); ic->methods = (XICMethods)&local_ic_methods; ic->core.im = im; diff --git a/lib/libX11/src/xlibi18n/XDefaultOMIF.c b/lib/libX11/src/xlibi18n/XDefaultOMIF.c index 1a707c842..9345547c3 100644 --- a/lib/libX11/src/xlibi18n/XDefaultOMIF.c +++ b/lib/libX11/src/xlibi18n/XDefaultOMIF.c @@ -182,61 +182,6 @@ check_charset( return (FontData) NULL; } -#if 0 /* Unused */ -static int -check_fontname( - XOC oc, - char *name) -{ - Display *dpy = oc->core.om->core.display; - XOCGenericPart *gen = XOC_GENERIC(oc); - FontData data; - FontSet font_set; - XFontStruct *fs_list; - char **fn_list, *fname, *prop_fname = NULL; - int list_num, i; - int list2_num; - char **fn2_list = NULL; - int found_num = 0; - - fn_list = XListFonts(dpy, name, MAXFONTS, &list_num); - if (fn_list == NULL) - return found_num; - - for (i = 0; i < list_num; i++) { - fname = fn_list[i]; - - font_set = gen->font_set; - - if ((data = check_charset(font_set, fname)) == NULL) { - if ((fn2_list = XListFontsWithInfo(dpy, name, MAXFONTS, - &list2_num, &fs_list)) - && (prop_fname = get_prop_name(dpy, fs_list)) - && (data = check_charset(font_set, prop_fname))) - fname = prop_fname; - } - if (data) { - font_set->font_name = strdup(fname); - if (font_set->font_name) { - found_num++; - } - } - if (fn2_list) { - XFreeFontInfo(fn2_list, fs_list, list2_num); - fn2_list = NULL; - if (prop_fname) { - Xfree(prop_fname); - prop_fname = NULL; - } - } - if (found_num == 1) - break; - } - XFreeFontNames(fn_list); - return found_num; -} -#endif - static Bool load_font( XOC oc) @@ -256,34 +201,6 @@ load_font( return True; } -#if 0 -static Bool -load_font_info( - XOC oc) -{ - Display *dpy = oc->core.om->core.display; - XOCGenericPart *gen = XOC_GENERIC(oc); - FontSet font_set = gen->font_set; - char **fn_list; - int fn_num; - - if (font_set->font_name == NULL) - return False; - - if (font_set->info == NULL) { - fn_list = XListFontsWithInfo(dpy, font_set->font_name, 1, &fn_num, - &font_set->info); - if (font_set->info == NULL) - return False; - if (fn_num > 0) - font_set->info->fid = XLoadFont(dpy, font_set->font_name); - - if (fn_list) XFreeFontNames(fn_list); - } - return True; -} -#endif - static void set_fontset_extents( XOC oc) @@ -320,16 +237,10 @@ init_core_part( FontSet font_set; XFontStruct **font_struct_list; char **font_name_list, *font_name_buf; - int count, length; font_set = gen->font_set; - count = length = 0; - if (font_set->font_name != NULL) { - length += strlen(font_set->font_name) + 1; - count++; - } - if (count == 0) + if (font_set->font_name == NULL) return False; font_struct_list = Xmalloc(sizeof(XFontStruct *)); @@ -340,7 +251,7 @@ init_core_part( if (font_name_list == NULL) goto err; - font_name_buf = Xmalloc(length); + font_name_buf = strdup(font_set->font_name); if (font_name_buf == NULL) goto err; @@ -348,19 +259,13 @@ init_core_part( oc->core.font_info.font_name_list = font_name_list; oc->core.font_info.font_struct_list = font_struct_list; - font_set = gen->font_set; - - if (font_set->font_name != NULL) { - font_set->id = 1; - if (font_set->font) - *font_struct_list++ = font_set->font; - else - *font_struct_list++ = font_set->info; - strcpy(font_name_buf, font_set->font_name); - Xfree(font_set->font_name); - *font_name_list++ = font_set->font_name = font_name_buf; - font_name_buf += strlen(font_name_buf) + 1; - } + font_set->id = 1; + if (font_set->font) + *font_struct_list = font_set->font; + else + *font_struct_list = font_set->info; + Xfree(font_set->font_name); + *font_name_list = font_set->font_name = font_name_buf; set_fontset_extents(oc); @@ -464,11 +369,7 @@ parse_fontname( found_num++; goto found; } -/* -1266793 -Limit the length of the string copy to prevent stack corruption. - strcpy(buf, pattern); -*/ + strncpy(buf, pattern, BUFSIZ); buf[BUFSIZ-1] = '\0'; length = strlen(buf); @@ -520,11 +421,6 @@ Limit the length of the string copy to prevent stack corruption. for ( ; font_data_count-- > 0; font_data++) { if (append_charset) { -/* -1266793 -Limit the length of the string copy to prevent stack corruption. - strcpy(last, font_data->name); -*/ strncpy(last, font_data->name, BUFSIZ - length); buf[BUFSIZ-1] = '\0'; } @@ -565,24 +461,17 @@ set_missing_list( XOCGenericPart *gen = XOC_GENERIC(oc); FontSet font_set; char **charset_list, *charset_buf; - int count, length; font_set = gen->font_set; - count = length = 0; - - if (!font_set->info && !font_set->font) { - length += strlen(font_set->font_data->name) + 1; - count++; - } - if (count == 0) + if (font_set->info == NULL || font_set->font == NULL) return True; charset_list = Xmalloc(sizeof(char *)); if (charset_list == NULL) return False; - charset_buf = Xmalloc(length); + charset_buf = strdup(font_set->font_data->name); if (charset_buf == NULL) { Xfree(charset_list); return False; @@ -590,13 +479,8 @@ set_missing_list( oc->core.missing_list.charset_list = charset_list; - font_set = gen->font_set; + *charset_list = charset_buf; - if (!font_set->info && !font_set->font) { - strcpy(charset_buf, font_set->font_data->name); - *charset_list++ = charset_buf; - charset_buf += strlen(charset_buf) + 1; - } return True; } @@ -1122,11 +1006,7 @@ add_data( static _Xconst char *supported_charset_list[] = { "ISO8859-1", -/* fix for bug4332979 */ "adobe-fontspecific", -/* fix for bug4237353: "JISX0201.1976-0" entry should be removed from - supported_charset_list because it is not a supported_charset for C locale - "JISX0201.1976-0", */ "SUNOLCURSOR-1", "SUNOLGLYPH-1" }; @@ -1141,7 +1021,7 @@ init_om( char **required_list; XOrientation *orientation; char *bufptr; - int i, count, length = 0; + int i, count; count = XlcNumber(supported_charset_list); @@ -1161,14 +1041,12 @@ init_om( return False; } - length += strlen(data->font_data->name) + 1; - /* required charset list */ required_list = Xmalloc(sizeof(char *)); if (required_list == NULL) return False; - bufptr = Xmalloc(length); + bufptr = strdup(data->font_data->name); if (bufptr == NULL) { Xfree(required_list); return False; @@ -1179,9 +1057,7 @@ init_om( data = gen->data; - strcpy(bufptr, data->font_data->name); - *required_list++ = bufptr; - bufptr += strlen(bufptr) + 1; + *required_list = bufptr; /* orientation list */ orientation = Xmalloc(sizeof(XOrientation)); diff --git a/lib/libX11/src/xlibi18n/XlcDL.c b/lib/libX11/src/xlibi18n/XlcDL.c index a23603865..bc71900a0 100644 --- a/lib/libX11/src/xlibi18n/XlcDL.c +++ b/lib/libX11/src/xlibi18n/XlcDL.c @@ -249,6 +249,7 @@ __lc_path(const char *dl_name, const char *lc_dir) { char *path; size_t len; + char *slash_p; /* * reject this for possible security issue @@ -264,22 +265,21 @@ __lc_path(const char *dl_name, const char *lc_dir) path = Xmalloc(len + 1); if (strchr(dl_name, '/') != NULL) { - char *slash_p; slash_p = strrchr(lc_dir, '/'); *slash_p = '\0'; - strcpy(path, lc_dir); strcat(path, "/"); + } else + slash_p = NULL; + #if defined POSTLOCALELIBDIR - strcat(path, POSTLOCALELIBDIR); strcat(path, "/"); + snprintf(path, len + 1, "%s/%s/%s.so.2", + lc_dir, POSTLOCALELIBDIR, dl_name); +#else + snprintf(path, len + 1, "%s/%s.so.2", lc_dir, dl_name); #endif - strcat(path, dl_name); strcat(path, ".so.2"); + + if (slash_p != NULL) *slash_p = '/'; - } else { - strcpy(path, lc_dir); strcat(path, "/"); -#if defined POSTLOCALELIBDIR - strcat(path, POSTLOCALELIBDIR); strcat(path, "/"); -#endif - strcat(path, dl_name); strcat(path, ".so.2"); - } + return path; } diff --git a/lib/libX11/src/xlibi18n/lcPrTxt.c b/lib/libX11/src/xlibi18n/lcPrTxt.c index 72fc2b927..77afd9372 100644 --- a/lib/libX11/src/xlibi18n/lcPrTxt.c +++ b/lib/libX11/src/xlibi18n/lcPrTxt.c @@ -149,7 +149,7 @@ _XTextPropertyToTextList( return XConverterNotFound; if (is_wide_char) { - buf_len = (text_prop->nitems + 1) * sizeof(wchar_t);; + buf_len = (text_prop->nitems + 1) * sizeof(wchar_t); } else { if (strcmp(to_type, XlcNUtf8String) == 0) buf_len = text_prop->nitems * 6 + 1; diff --git a/lib/libX11/src/xlibi18n/lcPubWrap.c b/lib/libX11/src/xlibi18n/lcPubWrap.c index d1096d570..3119918c6 100644 --- a/lib/libX11/src/xlibi18n/lcPubWrap.c +++ b/lib/libX11/src/xlibi18n/lcPubWrap.c @@ -78,10 +78,9 @@ _XlcCreateLC( return (XLCd) NULL; if (lcd->core->name == NULL) { - lcd->core->name = Xmalloc(strlen(name) + 1); + lcd->core->name = strdup(name); if (lcd->core->name == NULL) goto err; - strcpy(lcd->core->name, name); } if (lcd->methods == NULL) |