diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2017-09-16 07:42:35 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2017-09-16 07:42:35 +0000 |
commit | d2a31233fd1c8526b99983d69d5b20f296b76652 (patch) | |
tree | cc6bd6738afef216004ee32cc5547e6805349b99 /bin | |
parent | 03daef3d504bd3a41b800daf1d4e8be541681324 (diff) |
Carefully add casts to silence clang sign-compare warnings. ok millert@
Diffstat (limited to 'bin')
-rw-r--r-- | bin/pax/cpio.c | 10 | ||||
-rw-r--r-- | bin/pax/ftree.c | 4 | ||||
-rw-r--r-- | bin/pax/pat_rep.c | 4 | ||||
-rw-r--r-- | bin/pax/tables.c | 4 | ||||
-rw-r--r-- | bin/pax/tar.c | 9 |
5 files changed, 16 insertions, 15 deletions
diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c index fa78ae2bf60..92fe965163a 100644 --- a/bin/pax/cpio.c +++ b/bin/pax/cpio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpio.c,v 1.32 2017/09/12 17:11:11 otto Exp $ */ +/* $OpenBSD: cpio.c,v 1.33 2017/09/16 07:42:34 otto Exp $ */ /* $NetBSD: cpio.c,v 1.5 1995/03/21 09:07:13 cgd Exp $ */ /*- @@ -178,7 +178,7 @@ rd_nm(ARCHD *arcn, int nsz) /* * do not even try bogus values */ - if ((nsz == 0) || (nsz > sizeof(arcn->name))) { + if ((nsz == 0) || ((size_t)nsz > sizeof(arcn->name))) { paxwarn(1, "Cpio file name length %d is out of range", nsz); return(-1); } @@ -208,9 +208,9 @@ rd_ln_nm(ARCHD *arcn) /* * check the length specified for bogus values */ - if ((arcn->sb.st_size == 0) || - (arcn->sb.st_size >= sizeof(arcn->ln_name))) { - paxwarn(1, "Cpio link name length is invalid: %llu", + if ((arcn->sb.st_size <= 0) || + (arcn->sb.st_size >= (off_t)sizeof(arcn->ln_name))) { + paxwarn(1, "Cpio link name length is invalid: %lld", arcn->sb.st_size); return(-1); } diff --git a/bin/pax/ftree.c b/bin/pax/ftree.c index e45d4d43038..eb76a1e540a 100644 --- a/bin/pax/ftree.c +++ b/bin/pax/ftree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftree.c,v 1.40 2016/08/26 04:17:48 guenther Exp $ */ +/* $OpenBSD: ftree.c,v 1.41 2017/09/16 07:42:34 otto Exp $ */ /* $NetBSD: ftree.c,v 1.4 1995/03/21 09:07:21 cgd Exp $ */ /*- @@ -511,7 +511,7 @@ next_file(ARCHD *arcn) * copy file name, set file name length */ arcn->nlen = strlcpy(arcn->name, ftent->fts_path, sizeof(arcn->name)); - if (arcn->nlen >= sizeof(arcn->name)) + if ((size_t)arcn->nlen >= sizeof(arcn->name)) arcn->nlen = sizeof(arcn->name) - 1; /* XXX truncate? */ arcn->org_name = ftent->fts_path; return(0); diff --git a/bin/pax/pat_rep.c b/bin/pax/pat_rep.c index 0fbae0d3ccc..deddca0f72a 100644 --- a/bin/pax/pat_rep.c +++ b/bin/pax/pat_rep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pat_rep.c,v 1.42 2017/09/10 18:16:03 guenther Exp $ */ +/* $OpenBSD: pat_rep.c,v 1.43 2017/09/16 07:42:34 otto Exp $ */ /* $NetBSD: pat_rep.c,v 1.4 1995/03/21 09:07:33 cgd Exp $ */ /*- @@ -797,7 +797,7 @@ tty_rename(ARCHD *arcn) tty_prnt("Processing continues, name changed to: %s\n", tmpname); res = add_name(arcn->name, arcn->nlen, tmpname); arcn->nlen = strlcpy(arcn->name, tmpname, sizeof(arcn->name)); - if (arcn->nlen >= sizeof(arcn->name)) + if ((size_t)arcn->nlen >= sizeof(arcn->name)) arcn->nlen = sizeof(arcn->name) - 1; /* XXX truncate? */ if (res < 0) return(-1); diff --git a/bin/pax/tables.c b/bin/pax/tables.c index 5f39610c84a..a751de103db 100644 --- a/bin/pax/tables.c +++ b/bin/pax/tables.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tables.c,v 1.52 2017/09/12 17:11:11 otto Exp $ */ +/* $OpenBSD: tables.c,v 1.53 2017/09/16 07:42:34 otto Exp $ */ /* $NetBSD: tables.c,v 1.4 1995/03/21 09:07:45 cgd Exp $ */ /*- @@ -292,7 +292,7 @@ chk_lnk(ARCHD *arcn) arcn->ln_nlen = strlcpy(arcn->ln_name, pt->name, sizeof(arcn->ln_name)); /* XXX truncate? */ - if (arcn->nlen >= sizeof(arcn->name)) + if ((size_t)arcn->nlen >= sizeof(arcn->name)) arcn->nlen = sizeof(arcn->name) - 1; if (arcn->type == PAX_REG) arcn->type = PAX_HRG; diff --git a/bin/pax/tar.c b/bin/pax/tar.c index 88ca076f96f..5cd0702b7c2 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tar.c,v 1.65 2017/09/12 17:11:11 otto Exp $ */ +/* $OpenBSD: tar.c,v 1.66 2017/09/16 07:42:34 otto Exp $ */ /* $NetBSD: tar.c,v 1.5 1995/03/21 09:07:49 cgd Exp $ */ /*- @@ -550,7 +550,7 @@ tar_wr(ARCHD *arcn) case PAX_SLK: case PAX_HLK: case PAX_HRG: - if (arcn->ln_nlen > sizeof(hd->linkname)) { + if ((size_t)arcn->ln_nlen > sizeof(hd->linkname)) { paxwarn(1, "Link name too long for tar %s", arcn->ln_name); return(1); @@ -568,7 +568,7 @@ tar_wr(ARCHD *arcn) len = arcn->nlen; if (arcn->type == PAX_DIR) ++len; - if (len > sizeof(hd->name)) { + if ((size_t)len > sizeof(hd->name)) { paxwarn(1, "File name too long for tar %s", arcn->name); return(1); } @@ -941,7 +941,8 @@ ustar_wr(ARCHD *arcn) /* * check the length of the linkname */ - if (PAX_IS_LINK(arcn->type) && (arcn->ln_nlen > sizeof(hd->linkname))) { + if (PAX_IS_LINK(arcn->type) && + ((size_t)arcn->ln_nlen > sizeof(hd->linkname))) { paxwarn(1, "Link name too long for ustar %s", arcn->ln_name); return(1); } |