Date: Wed, 30 Oct 2013 18:40:55 +0000 (UTC) From: Sean Bruno <sbruno@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r257395 - head/usr.bin/xinstall Message-ID: <201310301840.r9UIetpm097937@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: sbruno Date: Wed Oct 30 18:40:55 2013 New Revision: 257395 URL: http://svnweb.freebsd.org/changeset/base/257395 Log: revert sign changes to buffers used in invocation of digest_update() Instead, change arguments of internal function digest_update() to accept signed char arguments. Remove MAP_FAILED fallback definition and casts of MAP_FAILED. Thanks to bde@ for looking over this and doing the code analysis. Modified: head/usr.bin/xinstall/xinstall.c Modified: head/usr.bin/xinstall/xinstall.c ============================================================================== --- head/usr.bin/xinstall/xinstall.c Wed Oct 30 18:33:40 2013 (r257394) +++ head/usr.bin/xinstall/xinstall.c Wed Oct 30 18:40:55 2013 (r257395) @@ -72,11 +72,6 @@ __FBSDID("$FreeBSD$"); #include "mtree.h" -/* Bootstrap aid - this doesn't exist in most older releases */ -#ifndef MAP_FAILED -#define MAP_FAILED ((void *)-1) /* from <sys/mman.h> */ -#endif - #define MAX_CMP_SIZE (16 * 1024 * 1024) #define LN_ABSOLUTE 0x01 @@ -126,7 +121,7 @@ static int create_tempfile(const char *, static char *quiet_mktemp(char *template); static char *digest_file(const char *); static void digest_init(DIGEST_CTX *); -static void digest_update(DIGEST_CTX *, const unsigned char *, size_t); +static void digest_update(DIGEST_CTX *, const char *, size_t); static char *digest_end(DIGEST_CTX *, char *); static int do_link(const char *, const char *, const struct stat *); static void do_symlink(const char *, const char *, const struct stat *); @@ -431,7 +426,7 @@ digest_init(DIGEST_CTX *c) } static void -digest_update(DIGEST_CTX *c, const unsigned char *data, size_t len) +digest_update(DIGEST_CTX *c, const char *data, size_t len) { switch (digesttype) { @@ -1002,7 +997,7 @@ compare(int from_fd, const char *from_na int to_fd, const char *to_name __unused, size_t to_len, char **dresp) { - unsigned char *p, *q; + char *p, *q; int rv; int done_compare; DIGEST_CTX ctx; @@ -1018,11 +1013,11 @@ compare(int from_fd, const char *from_na if (trymmap(from_fd) && trymmap(to_fd)) { p = mmap(NULL, from_len, PROT_READ, MAP_SHARED, from_fd, (off_t)0); - if (p == (unsigned char *)MAP_FAILED) + if (p == MAP_FAILED) goto out; q = mmap(NULL, from_len, PROT_READ, MAP_SHARED, to_fd, (off_t)0); - if (q == (unsigned char *)MAP_FAILED) { + if (q == MAP_FAILED) { munmap(p, from_len); goto out; } @@ -1036,7 +1031,7 @@ compare(int from_fd, const char *from_na } out: if (!done_compare) { - unsigned char buf1[MAXBSIZE]; + char buf1[MAXBSIZE]; char buf2[MAXBSIZE]; int n1, n2; @@ -1146,8 +1141,8 @@ copy(int from_fd, const char *from_name, { int nr, nw; int serrno; - unsigned char *p; - unsigned char buf[MAXBSIZE]; + char *p; + char buf[MAXBSIZE]; int done_copy; DIGEST_CTX ctx; @@ -1167,7 +1162,7 @@ copy(int from_fd, const char *from_name, done_copy = 0; if (size <= 8 * 1048576 && trymmap(from_fd) && (p = mmap(NULL, (size_t)size, PROT_READ, MAP_SHARED, - from_fd, (off_t)0)) != (unsigned char *)MAP_FAILED) { + from_fd, (off_t)0)) != MAP_FAILED) { nw = write(to_fd, p, size); if (nw != size) { serrno = errno;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310301840.r9UIetpm097937>