[Xfce4-commits] [apps/xfce4-taskmanager] 01/01: Fix random crash on an ugly string handling in bsd backend.

noreply at xfce.org noreply at xfce.org
Thu Dec 18 22:59:16 CET 2014


This is an automated email from the git hooks/post-receive script.

landry pushed a commit to branch master
in repository apps/xfce4-taskmanager.

commit 58689d26839e44137b02fd50bc8214691e3efed8
Author: Landry Breuil <landry at xfce.org>
Date:   Thu Dec 18 22:57:52 2014 +0100

    Fix random crash on an ugly string handling in bsd backend.
    
    Replace an horrible strlcat loop + g_snprintf by g_strjoinv + g_strlcpy.
    Assert that the buffer is valid UTF8, blow otherwise.
---
 src/task-manager-bsd.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/task-manager-bsd.c b/src/task-manager-bsd.c
index e8a06c7..0539f85 100644
--- a/src/task-manager-bsd.c
+++ b/src/task-manager-bsd.c
@@ -56,7 +56,7 @@ gboolean get_task_list (GArray *task_list)
 	Task t;
 	struct passwd *passwdp;
 	char **args, **ptr;
-	char buf[127];
+	gchar* buf;
 	int nproc, i;
 
 	mib[0] = CTL_KERN;
@@ -132,14 +132,11 @@ gboolean get_task_list (GArray *task_list)
 					break;
 				}
 			}
-			buf[0] = '\0';
-			for (ptr = args; *ptr != NULL; ptr++) {
-				if (ptr != args)
-					strlcat(buf, " ", sizeof(buf));
-				strlcat(buf, *ptr, sizeof(buf));
-			}
+			buf = g_strjoinv(" ", args);
+			g_assert(g_utf8_validate(buf, -1, NULL));
+			g_strlcpy(t.cmdline, buf, sizeof t.cmdline);
+			g_free(buf);
 			free(args);
-			g_snprintf(t.cmdline, sizeof t.cmdline, "%s", buf);
 		}
 
 		t.cpu_user = (100.0 * ((double) p.p_pctcpu / FSCALE));

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list