void
chopt_init (struct Chown_option *);
-void _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_CONST
-chopt_free (struct Chown_option *);
+void chopt_free (struct Chown_option *);
-char *
-gid_to_name (gid_t);
+char *gid_to_name (gid_t) _GL_ATTRIBUTE_MALLOC;
-char * _GL_ATTRIBUTE_PURE
-uid_to_name (uid_t);
+char *uid_to_name (uid_t) _GL_ATTRIBUTE_MALLOC;
bool
chown_files (char **files, int bit_flags,
static char *
make_id_equals_comment (STRUCT_UTMP const *utmp_ent)
{
- char *comment = xmalloc (strlen (_("id=")) + sizeof UT_ID (utmp_ent) + 1);
-
- strcpy (comment, _("id="));
- strncat (comment, UT_ID (utmp_ent), sizeof UT_ID (utmp_ent));
+ char const *ideq = _("id=");
+ char const *ut_id = UT_ID (utmp_ent);
+ size_t ideqlen = strlen (ideq);
+ size_t ut_idlen = strnlen (ut_id, sizeof UT_ID (utmp_ent));
+ char *comment = xmalloc (ideqlen + ut_idlen + 1);
+ char *rhs = mempcpy (comment, ideq, ideqlen);
+ char *z = mempcpy (rhs, ut_id, ut_idlen);
+ *z = '\0';
return comment;
}