* [PATCH] nss_nisplus/nisplus-alias.c: fix build warning on gcc7
@ 2017-05-24 11:13 Yury Norov
2017-05-24 11:56 ` Andreas Schwab
0 siblings, 1 reply; 3+ messages in thread
From: Yury Norov @ 2017-05-24 11:13 UTC (permalink / raw)
To: libc-alpha; +Cc: Yury Norov
Hi all,
gcc7 for arm64 warns about NULL pointer passed to strlen() and
snprintf() in _nss_nisplus_getaliasbyname_r(). If Werror is enabled,
it is treaded as error, and so breask build:
nss_nisplus/nisplus-alias.c: In function
â_nss_nisplus_getaliasbyname_râ:
nss_nisplus/nisplus-alias.c:300:12: error: argument 1 null where
non-null expected [-Werror=nonnull]
char buf[strlen (name) + 9 + tablename_len];
^~~~~~~~~~~~~
In file included from ../include/string.h:54:0,
from nss_nisplus/nisplus-alias.c:23:
../string/string.h:394:15: note: in a call to function âstrlenâ declared here
extern size_t strlen (const char *__s)
^~~~~~
nss_nisplus/nisplus-alias.c:303:39: error: â%sâ directive argument is null [-Werror=format-truncation=]
snprintf (buf, sizeof (buf), "[name=%s],%s", name, tablename_val);
^~
cc1: all warnings being treated as errors
* nis/nss_nisplus/nisplus-alias.c: don't pass name variable
known to be NULL to strlen() and snprintf() in
_nss_nisplus_getaliasbyname_r()
If the line "[name=],..." looks weird, I'll resend the patch, if someone will
hint me how it should look. Anyway, I think that it currently should look like
this.
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
nis/nss_nisplus/nisplus-alias.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/nis/nss_nisplus/nisplus-alias.c b/nis/nss_nisplus/nisplus-alias.c
index 7f698b4e6d..509ace1f83 100644
--- a/nis/nss_nisplus/nisplus-alias.c
+++ b/nis/nss_nisplus/nisplus-alias.c
@@ -297,10 +297,10 @@ _nss_nisplus_getaliasbyname_r (const char *name, struct aliasent *alias,
return NSS_STATUS_UNAVAIL;
}
- char buf[strlen (name) + 9 + tablename_len];
+ char buf[tablename_len + 9];
int olderr = errno;
- snprintf (buf, sizeof (buf), "[name=%s],%s", name, tablename_val);
+ snprintf (buf, sizeof (buf), "[name=],%s", tablename_val);
nis_result *result = nis_list (buf, FOLLOW_PATH | FOLLOW_LINKS, NULL, NULL);
--
2.11.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nss_nisplus/nisplus-alias.c: fix build warning on gcc7
2017-05-24 11:13 [PATCH] nss_nisplus/nisplus-alias.c: fix build warning on gcc7 Yury Norov
@ 2017-05-24 11:56 ` Andreas Schwab
2017-05-24 12:07 ` Yury Norov
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2017-05-24 11:56 UTC (permalink / raw)
To: Yury Norov; +Cc: libc-alpha
Please update your sources.
commit f88759ea9b
Author: Joseph Myers <joseph@codesourcery.com>
Date: Wed Dec 21 23:44:01 2016 +0000
Fix nss_nisplus build with mainline GCC (bug 20978).
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nss_nisplus/nisplus-alias.c: fix build warning on gcc7
2017-05-24 11:56 ` Andreas Schwab
@ 2017-05-24 12:07 ` Yury Norov
0 siblings, 0 replies; 3+ messages in thread
From: Yury Norov @ 2017-05-24 12:07 UTC (permalink / raw)
To: Andreas Schwab; +Cc: libc-alpha
On Wed, May 24, 2017 at 01:56:43PM +0200, Andreas Schwab wrote:
> Please update your sources.
>
> commit f88759ea9b
> Author: Joseph Myers <joseph@codesourcery.com>
> Date: Wed Dec 21 23:44:01 2016 +0000
>
> Fix nss_nisplus build with mainline GCC (bug 20978).
>
> Andreas.
Ah, sorry that. Then forget.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-24 12:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-24 11:13 [PATCH] nss_nisplus/nisplus-alias.c: fix build warning on gcc7 Yury Norov
2017-05-24 11:56 ` Andreas Schwab
2017-05-24 12:07 ` Yury Norov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).