Bug 1741515

Summary: glibc: Add nonstring attributes to <utmp.h>, <utmpx.h>
Product: Red Hat Enterprise Linux 7 Reporter: Florian Weimer <fweimer>
Component: glibcAssignee: glibc team <glibc-bugzilla>
Status: CLOSED WONTFIX QA Contact: qe-baseos-tools-bugs
Severity: low Docs Contact:
Priority: low    
Version: 7.7CC: ashankar, codonell, dj, fweimer, mnewsome, pfrankli
Target Milestone: rc   
Target Release: 7.8   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1741516 (view as bug list) Environment:
Last Closed: 2019-11-25 16:27:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1741516, 1749439    
Bug Blocks:    

Description Florian Weimer 2019-08-15 11:03:25 UTC
This file should compile without warnings using -O2 -Wall, using GCC 9 (or later):

#include <string.h>
#include <utmp.h>
#include <utmpx.h>

void
write_utmp (struct utmp *p, const char *data)
{
  strncpy (p->ut_line, data, sizeof (p->ut_line));
  strncpy (p->ut_id, data, sizeof (p->ut_id));
  strncpy (p->ut_user, data, sizeof (p->ut_user));
  strncpy (p->ut_host, data, sizeof (p->ut_host));
}

void
write_utmpx (struct utmpx *p, const char *data)
{
  strncpy (p->ut_line, data, sizeof (p->ut_line));
  strncpy (p->ut_id, data, sizeof (p->ut_id));
  strncpy (p->ut_user, data, sizeof (p->ut_user));
  strncpy (p->ut_host, data, sizeof (p->ut_host));
}

Since the suppression of warnings in system headers is not effective here, I think we should backport the upstream fixes to support Developer Toolset 9 and later.