xserver: Branch 'master' - 8 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Oct 16 00:49:52 UTC 2019


 Xext/hashtable.c   |    2 +-
 dix/privates.c     |    6 ++++--
 dix/resource.c     |    4 ++--
 include/resource.h |    3 +--
 mi/micmap.c        |    8 ++++----
 mi/mieq.c          |   12 +++++++-----
 record/record.c    |    3 ++-
 render/picture.c   |    6 ++++--
 8 files changed, 25 insertions(+), 19 deletions(-)

New commits:
commit 55482c1caf4dbe7f4735b75366bd4acd81937fc1
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 15 13:40:01 2019 -0400

    render: Fix undefined shift in xRenderColorToCard32
    
    Delightfully this is undefined even though CARD16 is an "unsigned" type,
    because it's an unsigned short, which C promotes to signed int because
    everything is stupid.

diff --git a/render/picture.c b/render/picture.c
index c8f24f7f4..876316dc1 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -793,8 +793,10 @@ static CARD32
 xRenderColorToCard32(xRenderColor c)
 {
     return
-        (c.alpha >> 8 << 24) |
-        (c.red >> 8 << 16) | (c.green & 0xff00) | (c.blue >> 8);
+        ((unsigned)c.alpha >> 8 << 24) |
+        ((unsigned)c.red >> 8 << 16) |
+        ((unsigned)c.green & 0xff00) |
+        ((unsigned)c.blue >> 8);
 }
 
 static void
commit 592525386ad81cf9c8816f42f01a5bea01034e98
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 15 13:32:36 2019 -0400

    dix: Fix undefined memset in _dixInitScreenPrivates
    
    Again, memset(0, ...) is undefined.

diff --git a/dix/privates.c b/dix/privates.c
index 3f768ef3e..384936fbd 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -684,7 +684,8 @@ _dixInitScreenPrivates(ScreenPtr pScreen, PrivatePtr *privates, void *addr, DevP
     if (privates_size == 0)
         addr = 0;
     *privates = addr;
-    memset(addr, '\0', privates_size);
+    if (addr)
+        memset(addr, '\0', privates_size);
 }
 
 void *
commit f44ac101c523a0439bd1a864850e3c1a4e154549
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 15 13:21:37 2019 -0400

    record: Fix undefined memcpy in RecordAClientStateChange
    
    If we don't have any recording contexts just skip all this. Note this
    also skips a pointless trip through malloc(0)/free.

diff --git a/record/record.c b/record/record.c
index 3a1b00516..757fde1fe 100644
--- a/record/record.c
+++ b/record/record.c
@@ -2729,7 +2729,8 @@ RecordAClientStateChange(CallbackListPtr *pcbl, void *nulldata,
     case ClientStateRetained:  /* client disconnected */
 
         /* RecordDisableContext modifies contents of ppAllContexts. */
-        numContextsCopy = numContexts;
+        if (!(numContextsCopy = numContexts))
+            break;
         ppAllContextsCopy = xallocarray(numContextsCopy,
                                         sizeof(RecordContextPtr));
         assert(ppAllContextsCopy);
commit 9155e0c7c6696ec8c657e32bf41a08f88a8f3d0d
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 15 13:16:17 2019 -0400

    mi: Fix undefined memcpy in mieqGrowQueue
    
    The first time we get here, eventQueue->events is NULL.

diff --git a/mi/mieq.c b/mi/mieq.c
index 157724b2d..09b71b639 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -126,11 +126,13 @@ mieqGrowQueue(EventQueuePtr eventQueue, size_t new_nevents)
 
     /* First copy the existing events */
     first_hunk = eventQueue->nevents - eventQueue->head;
-    memcpy(new_events,
-           &eventQueue->events[eventQueue->head],
-           first_hunk * sizeof(EventRec));
-    memcpy(&new_events[first_hunk],
-           eventQueue->events, eventQueue->head * sizeof(EventRec));
+    if (eventQueue->events) {
+        memcpy(new_events,
+               &eventQueue->events[eventQueue->head],
+               first_hunk * sizeof(EventRec));
+        memcpy(&new_events[first_hunk],
+               eventQueue->events, eventQueue->head * sizeof(EventRec));
+    }
 
     /* Initialize the new portion */
     for (i = eventQueue->nevents; i < new_nevents; i++) {
commit 6fe7c43fa52ffa9b91887ea7f8044e54b12637c9
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 15 13:10:35 2019 -0400

    dix: Fix undefined shift in ht_generic_hash
    
    The hits keep coming.

diff --git a/Xext/hashtable.c b/Xext/hashtable.c
index 93d1a2aec..3434c9948 100644
--- a/Xext/hashtable.c
+++ b/Xext/hashtable.c
@@ -240,7 +240,7 @@ unsigned
 ht_generic_hash(void *cdata, const void *ptr, int numBits)
 {
     HtGenericHashSetupPtr setup = cdata;
-    return one_at_a_time_hash(ptr, setup->keySize) & ~((~0) << numBits);
+    return one_at_a_time_hash(ptr, setup->keySize) & ~((~0U) << numBits);
 }
 
 int
commit 1e5f478b7e1183d38ad07d1f5e68fdc9680f2eb8
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 15 13:08:57 2019 -0400

    dix: Fix undefined shift in HashResourceID
    
    Again, we need all of the bits of an unsigned int to make this work.

diff --git a/dix/resource.c b/dix/resource.c
index a42cd007f..6c0be2e04 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -671,7 +671,7 @@ InitClientResources(ClientPtr client)
 }
 
 int
-HashResourceID(XID id, int numBits)
+HashResourceID(XID id, unsigned int numBits)
 {
     static XID mask;
 
@@ -679,7 +679,7 @@ HashResourceID(XID id, int numBits)
         mask = RESOURCE_ID_MASK;
     id &= mask;
     if (numBits < 9)
-        return (id ^ (id >> numBits) ^ (id >> (numBits<<1))) & ~((~0) << numBits);
+        return (id ^ (id >> numBits) ^ (id >> (numBits<<1))) & ~((~0U) << numBits);
     return (id ^ (id >> numBits)) & ~((~0) << numBits);
 }
 
diff --git a/include/resource.h b/include/resource.h
index 5871a4cb4..6caf846c4 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -270,7 +270,6 @@ extern _X_EXPORT RESTYPE TypeMask;
     of bits by either masking numBits lower bits of the ID or by
     providing at most MAXHASHSIZE hashes.
 */
-extern _X_EXPORT int HashResourceID(XID id,
-                                    int numBits);
+extern _X_EXPORT int HashResourceID(XID id, unsigned int numBits);
 
 #endif /* RESOURCE_H */
commit 3671a3ee88dac3cf1a301adf27dc2b43b069815b
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 15 13:01:27 2019 -0400

    mi: Fix undefined shift in miSetVisualTypesAndMasks
    
    The masks we end up building will occupy all 32 bits of an unsigned int,
    which means we had better build the shifts out of unsigned ints, because
    left-shifting a signed int all the way into the sign bit is undefined.

diff --git a/mi/micmap.c b/mi/micmap.c
index 5743adb19..8b7ecd27f 100644
--- a/mi/micmap.c
+++ b/mi/micmap.c
@@ -278,14 +278,14 @@ miCreateDefColormap(ScreenPtr pScreen)
 
 #define _RZ(d) ((d + 2) / 3)
 #define _RS(d) 0
-#define _RM(d) ((1 << _RZ(d)) - 1)
+#define _RM(d) ((1U << _RZ(d)) - 1)
 #define _GZ(d) ((d - _RZ(d) + 1) / 2)
 #define _GS(d) _RZ(d)
-#define _GM(d) (((1 << _GZ(d)) - 1) << _GS(d))
+#define _GM(d) (((1U << _GZ(d)) - 1) << _GS(d))
 #define _BZ(d) (d - _RZ(d) - _GZ(d))
 #define _BS(d) (_RZ(d) + _GZ(d))
-#define _BM(d) (((1 << _BZ(d)) - 1) << _BS(d))
-#define _CE(d) (1 << _RZ(d))
+#define _BM(d) (((1U << _BZ(d)) - 1) << _BS(d))
+#define _CE(d) (1U << _RZ(d))
 
 typedef struct _miVisuals {
     struct _miVisuals *next;
commit a41d45eedc0c217c28def47acbd8759e31706b96
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Oct 15 11:59:39 2019 -0400

    dix: Fix undefined memset in dixInitPrivates
    
    When we set these up initially, no subsystems have allocated any
    privates yet, so the storage address will be null, and memset(NULL, ...)
    is undefined.

diff --git a/dix/privates.c b/dix/privates.c
index 83dfabc47..3f768ef3e 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -447,7 +447,8 @@ _dixInitPrivates(PrivatePtr *privates, void *addr, DevPrivateType type)
     if (global_keys[type].offset == 0)
         addr = 0;
     *privates = addr;
-    memset(addr, '\0', global_keys[type].offset);
+    if (addr)
+        memset(addr, '\0', global_keys[type].offset);
 }
 
 /*


More information about the xorg-commit mailing list