From: Steve Dickson <SteveD@RedHat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH] Removed -Werror=format-truncation and format warnings
Date: Sat, 10 Mar 2018 11:34:34 -0500 [thread overview]
Message-ID: <c8b09ac2-ba19-1f23-548b-5af5baf95aff@RedHat.com> (raw)
In-Reply-To: <20180307193002.46760-1-steved@redhat.com>
On 03/07/2018 02:30 PM, Steve Dickson wrote:
> Signed-off-by: Steve Dickson <steved@redhat.com>
> ---
> tools/locktest/testlk.c | 2 +-
> utils/blkmapd/device-discovery.c | 2 +-
> utils/gssd/krb5_util.c | 24 ++++++++++--------------
> utils/idmapd/idmapd.c | 2 +-
> 4 files changed, 13 insertions(+), 17 deletions(-)
Committed...
steved.
>
> diff --git a/tools/locktest/testlk.c b/tools/locktest/testlk.c
> index 82ed765..b392f71 100644
> --- a/tools/locktest/testlk.c
> +++ b/tools/locktest/testlk.c
> @@ -81,7 +81,7 @@ main(int argc, char **argv)
> if (fl.l_type == F_UNLCK) {
> printf("%s: no conflicting lock\n", fname);
> } else {
> - printf("%s: conflicting lock by %d on (%lld;%lld)\n",
> + printf("%s: conflicting lock by %d on (%ld;%ld)\n",
> fname, fl.l_pid, fl.l_start, fl.l_len);
> }
> return 0;
> diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c
> index 1afc80f..3a202e0 100644
> --- a/utils/blkmapd/device-discovery.c
> +++ b/utils/blkmapd/device-discovery.c
> @@ -239,7 +239,7 @@ int bl_discover_devices(void)
> {
> FILE *f;
> int n;
> - char buf[PATH_MAX], devname[PATH_MAX], fulldevname[PATH_MAX];
> + char buf[PATH_MAX], devname[PATH_MAX], fulldevname[PATH_MAX+NAME_MAX];
>
> /* release previous list */
> bl_release_disk();
> diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
> index 6e61da2..b342b06 100644
> --- a/utils/gssd/krb5_util.c
> +++ b/utils/gssd/krb5_util.c
> @@ -188,7 +188,7 @@ gssd_find_existing_krb5_ccache(uid_t uid, char *dirname,
> int found = 0;
> struct dirent *best_match_dir = NULL;
> struct stat best_match_stat, tmp_stat;
> - char buf[1030];
> + char buf[PATH_MAX+4+2+256];
> char *princname = NULL;
> char *realm = NULL;
> int score, best_match_score = 0, err = -EACCES;
> @@ -202,39 +202,35 @@ gssd_find_existing_krb5_ccache(uid_t uid, char *dirname,
> dirname, strerror(errno));
> }
> else if (n > 0) {
> - char statname[1024];
> for (i = 0; i < n; i++) {
> - snprintf(statname, sizeof(statname),
> + snprintf(buf, sizeof(buf),
> "%s/%s", dirname, namelist[i]->d_name);
> printerr(3, "CC '%s' being considered, "
> "with preferred realm '%s'\n",
> - statname, preferred_realm ?
> + buf, preferred_realm ?
> preferred_realm : "<none selected>");
> - if (lstat(statname, &tmp_stat)) {
> - printerr(0, "Error doing stat on '%s'\n",
> - statname);
> + if (lstat(buf, &tmp_stat)) {
> + printerr(0, "Error doing stat on '%s'\n", buf);
> free(namelist[i]);
> continue;
> }
> /* Only pick caches owned by the user (uid) */
> if (tmp_stat.st_uid != uid) {
> printerr(3, "CC '%s' owned by %u, not %u\n",
> - statname, tmp_stat.st_uid, uid);
> + buf, tmp_stat.st_uid, uid);
> free(namelist[i]);
> continue;
> }
> if (!S_ISREG(tmp_stat.st_mode) &&
> !S_ISDIR(tmp_stat.st_mode)) {
> printerr(3, "CC '%s' is not a regular "
> - "file or directory\n",
> - statname);
> + "file or directory\n", buf);
> free(namelist[i]);
> continue;
> }
> if (uid == 0 && !root_uses_machine_creds &&
> strstr(namelist[i]->d_name, "machine_")) {
> - printerr(3, "CC '%s' not available to root\n",
> - statname);
> + printerr(3, "CC '%s' not available to root\n", buf);
> free(namelist[i]);
> continue;
> }
> @@ -865,7 +861,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *tgtname,
> if (strcmp(realm, default_realm) == 0)
> tried_default = 1;
> for (j = 0; svcnames[j] != NULL; j++) {
> - char spn[300];
> + char spn[NI_MAXHOST+2];
>
> /*
> * The special svcname "$" means 'try the active
> @@ -1059,7 +1055,7 @@ err_cache:
> int
> gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername, char *dirpattern)
> {
> - char buf[MAX_NETOBJ_SZ], dirname[PATH_MAX];
> + char buf[PATH_MAX+2+256], dirname[PATH_MAX];
> const char *cctype;
> struct dirent *d;
> int err, i, j;
> diff --git a/utils/idmapd/idmapd.c b/utils/idmapd/idmapd.c
> index 67d115d..b87c4dd 100644
> --- a/utils/idmapd/idmapd.c
> +++ b/utils/idmapd/idmapd.c
> @@ -420,7 +420,7 @@ dirscancb(int UNUSED(fd), short UNUSED(which), void *data)
> int nent, i;
> struct dirent **ents;
> struct idmap_client *ic, *nextic;
> - char path[PATH_MAX];
> + char path[PATH_MAX+256]; /* + sizeof(d_name) */
> struct idmap_clientq *icq = data;
>
> nent = scandir(pipefsdir, &ents, NULL, alphasort);
>
prev parent reply other threads:[~2018-03-10 16:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-07 19:30 [PATCH] Removed -Werror=format-truncation and format warnings Steve Dickson
2018-03-10 16:34 ` Steve Dickson [this message]
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=c8b09ac2-ba19-1f23-548b-5af5baf95aff@RedHat.com \
--to=steved@redhat.com \
--cc=linux-nfs@vger.kernel.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