Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- login-utils/chfn.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/login-utils/chfn.c b/login-utils/chfn.c index ca6f456..4746927 100644 --- a/login-utils/chfn.c +++ b/login-utils/chfn.c @@ -324,12 +324,8 @@ static int save_new_data(struct finfo *pinfo) pinfo->other = ""; /* create the new gecos string */ - len = (strlen(pinfo->full_name) + strlen(pinfo->office) + - strlen(pinfo->office_phone) + strlen(pinfo->home_phone) + - strlen(pinfo->other) + 4); - gecos = (char *)xmalloc(len + 1); - sprintf(gecos, "%s,%s,%s,%s,%s", pinfo->full_name, pinfo->office, - pinfo->office_phone, pinfo->home_phone, pinfo->other); + len = xasprintf(&gecos, "%s,%s,%s,%s,%s", pinfo->full_name, pinfo->office, + pinfo->office_phone, pinfo->home_phone, pinfo->other); /* remove trailing empty fields (but not subfields of pinfo->other) */ if (!pinfo->other[0]) { @@ -351,6 +347,7 @@ static int save_new_data(struct finfo *pinfo) ("Finger information *NOT* changed. Try again later.\n")); return -1; } + free(gecos); printf(_("Finger information changed.\n")); return 0; } -- 2.1.3 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html