@cryptotaxi247 / netdata-1 / commits / 97496624e

properly check that users and groups have a name; fixes #2321

Costa Tsaousis (ktsaou) committed Jun 13, 2017 at 22:44 UTC 97496624ed386392b1e2e6a5f2d971449057b4e7
1 file changed +2 -2
src/apps_plugin.c
+2 -2
@@ -437,7 +437,7 @@ static struct target *get_users_target(uid_t uid) {
437 w->idhash = simple_hash(w->id);
438
439 struct passwd *pw = getpwuid(uid);
440 - if(!pw)
440 + if(!pw || !pw->pw_name || !*pw->pw_name)
441 snprintfz(w->name, MAX_NAME, "%u", uid);
442 else
443 snprintfz(w->name, MAX_NAME, "%s", pw->pw_name);
@@ -470,7 +470,7 @@ struct target *get_groups_target(gid_t gid)
470 w->idhash = simple_hash(w->id);
471
472 struct group *gr = getgrgid(gid);
473 - if(!gr)
473 + if(!gr || !gr->gr_name || !*gr->gr_name)
474 snprintfz(w->name, MAX_NAME, "%u", gid);
475 else
476 snprintfz(w->name, MAX_NAME, "%s", gr->gr_name);