xserver: Branch 'master' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Sep 1 23:04:55 UTC 2024


 os/client.c |   29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

New commits:
commit 59f5445a7ff3ee1468d86f03943c976c790c0893
Author: Matthieu Herrb <matthieu at herrb.eu>
Date:   Sat Feb 17 16:47:38 2024 +0100

    Return NULL in *cmdname if the client argv or argv[0] is NULL
    
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/995>

diff --git a/os/client.c b/os/client.c
index 7752591aa..5c5278c32 100644
--- a/os/client.c
+++ b/os/client.c
@@ -326,10 +326,9 @@ DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
             return;
         argv = kvm_getargv(kd, kp, 0);
         if (cmdname) {
-            if (argv == NULL || argv[0] == NULL) {
-                *cmdname = strdup("");
+            if (argv == NULL || argv[0] == NULL)
                 return;
-            } else
+            else
                 *cmdname = strdup(argv[0]);
         }
         if (cmdargs) {
commit a8512146ba9f475a384a35337f51c7730ba7b4ce
Author: Matthieu Herrb <matthieu at herrb.eu>
Date:   Fri Nov 11 14:58:02 2022 +0100

    Don't crash if the client argv or argv[0] is NULL.
    
    Report from  bauerm at pestilenz dot org.
    
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/995>

diff --git a/os/client.c b/os/client.c
index 6a119afc1..7752591aa 100644
--- a/os/client.c
+++ b/os/client.c
@@ -325,18 +325,26 @@ DetermineClientCmd(pid_t pid, const char **cmdname, const char **cmdargs)
         if (n != 1)
             return;
         argv = kvm_getargv(kd, kp, 0);
-        *cmdname = strdup(argv[0]);
-        i = 1;
-        while (argv[i] != NULL) {
-            len += strlen(argv[i]) + 1;
-            i++;
+        if (cmdname) {
+            if (argv == NULL || argv[0] == NULL) {
+                *cmdname = strdup("");
+                return;
+            } else
+                *cmdname = strdup(argv[0]);
         }
-        *cmdargs = calloc(1, len);
-        i = 1;
-        while (argv[i] != NULL) {
-            strlcat(*cmdargs, argv[i], len);
-            strlcat(*cmdargs, " ", len);
-            i++;
+        if (cmdargs) {
+            i = 1;
+            while (argv[i] != NULL) {
+                len += strlen(argv[i]) + 1;
+                i++;
+            }
+            *cmdargs = calloc(1, len);
+            i = 1;
+            while (argv[i] != NULL) {
+                strlcat(*(char **)cmdargs, argv[i], len);
+                strlcat(*(char **)cmdargs, " ", len);
+                i++;
+            }
         }
         kvm_close(kd);
     }


More information about the xorg-commit mailing list