aboutsummaryrefslogtreecommitdiff
path: root/hardinfo2
diff options
context:
space:
mode:
authorAndrey Esin <gmlastik@gmail.com>2009-08-26 18:23:57 +0800
committerLeandro A. F. Pereira <leandro@hardinfo.org>2009-08-27 10:55:37 +0800
commit0a8eb9c89866abee76a31078599980dfc8bea338 (patch)
tree8798c1ba0f5f27c27bf2029e8faa9cbea49ddd3c /hardinfo2
parent146bd3affa91e26c59b70016110bec657915d9b3 (diff)
Emtpy line in /etc/passwd leads to crash of hardinfo.
Signed-off-by: Leandro A. F. Pereira <leandro@hardinfo.org>
Diffstat (limited to 'hardinfo2')
-rw-r--r--hardinfo2/arch/common/users.h29
1 files changed, 15 insertions, 14 deletions
diff --git a/hardinfo2/arch/common/users.h b/hardinfo2/arch/common/users.h
index 2361a4bf..cb86bdff 100644
--- a/hardinfo2/arch/common/users.h
+++ b/hardinfo2/arch/common/users.h
@@ -29,21 +29,22 @@ scan_users_do(void)
gint uid;
tmp = g_strsplit(buffer, ":", 0);
-
- gchar *key = g_strdup_printf("USER%s", tmp[0]);
- gchar *val = g_strdup_printf("[User Information]\n"
- "User ID=%s\n"
- "Group ID=%s\n"
- "Home directory=%s\n"
- "Default shell=%s\n",
- tmp[2], tmp[3], tmp[5], tmp[6]);
- g_hash_table_insert(moreinfo, key, val);
+ if (strlen(tmp[0]) > 1) {
+ gchar *key = g_strdup_printf("USER%s", tmp[0]);
+ gchar *val = g_strdup_printf("[User Information]\n"
+ "User ID=%s\n"
+ "Group ID=%s\n"
+ "Home directory=%s\n"
+ "Default shell=%s\n",
+ tmp[2], tmp[3], tmp[5], tmp[6]);
+ g_hash_table_insert(moreinfo, key, val);
- uid = atoi(tmp[2]);
- strend(tmp[4], ',');
- users = h_strdup_cprintf("$%s$%s=%s\n", users, key, tmp[0], tmp[4]);
-
- g_strfreev(tmp);
+ uid = atoi(tmp[2]);
+ strend(tmp[4], ',');
+ users = h_strdup_cprintf("$%s$%s=%s\n", users, key, tmp[0], tmp[4]);
+
+ g_strfreev(tmp);
+ }
}
fclose(passwd);