From: Yury Norov <ynorov@caviumnetworks.com>
To: libc-alpha@sourceware.org
Cc: Yury Norov <ynorov@caviumnetworks.com>
Subject: [PATCH] nss_nisplus/nisplus-alias.c: fix build warning on gcc7
Date: Wed, 24 May 2017 11:13:00 -0000 [thread overview]
Message-ID: <20170524111338.3495-1-ynorov@caviumnetworks.com> (raw)
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
next reply other threads:[~2017-05-24 11:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-24 11:13 Yury Norov [this message]
2017-05-24 11:56 ` Andreas Schwab
2017-05-24 12:07 ` Yury Norov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170524111338.3495-1-ynorov@caviumnetworks.com \
--to=ynorov@caviumnetworks.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).