]> git.sur5r.net Git - i3/i3/blobdiff - i3bar/src/ipc.c
Fixes for undefined behaviour on signed shift (#3453)
[i3/i3] / i3bar / src / ipc.c
index 7a657338472e7fd6941e38a82b3e7eaf78e1654f..9a7fb21eb401038c1a63376d36a2874ddc3d4a25 100644 (file)
@@ -278,8 +278,8 @@ void got_data(struct ev_loop *loop, ev_io *watcher, int events) {
     buffer[size] = '\0';
 
     /* And call the callback (indexed by the type) */
-    if (type & (1 << 31)) {
-        type ^= 1 << 31;
+    if (type & (1UL << 31)) {
+        type ^= 1UL << 31;
         event_handlers[type](buffer);
     } else {
         if (reply_handlers[type])
@@ -309,7 +309,7 @@ int i3_send_msg(uint32_t type, const char *payload) {
     char *buffer = smalloc(to_write);
     char *walk = buffer;
 
-    strncpy(buffer, I3_IPC_MAGIC, strlen(I3_IPC_MAGIC));
+    memcpy(buffer, I3_IPC_MAGIC, strlen(I3_IPC_MAGIC));
     walk += strlen(I3_IPC_MAGIC);
     memcpy(walk, &len, sizeof(uint32_t));
     walk += sizeof(uint32_t);