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.
This commit is contained in:
parent
a856a96409
commit
538d90d30d
@ -72,11 +72,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include "mtree.h"
|
#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 MAX_CMP_SIZE (16 * 1024 * 1024)
|
||||||
|
|
||||||
#define LN_ABSOLUTE 0x01
|
#define LN_ABSOLUTE 0x01
|
||||||
@ -126,7 +121,7 @@ static int create_tempfile(const char *, char *, size_t);
|
|||||||
static char *quiet_mktemp(char *template);
|
static char *quiet_mktemp(char *template);
|
||||||
static char *digest_file(const char *);
|
static char *digest_file(const char *);
|
||||||
static void digest_init(DIGEST_CTX *);
|
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 char *digest_end(DIGEST_CTX *, char *);
|
||||||
static int do_link(const char *, const char *, const struct stat *);
|
static int do_link(const char *, const char *, const struct stat *);
|
||||||
static void do_symlink(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
|
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) {
|
switch (digesttype) {
|
||||||
@ -1002,7 +997,7 @@ compare(int from_fd, const char *from_name __unused, size_t from_len,
|
|||||||
int to_fd, const char *to_name __unused, size_t to_len,
|
int to_fd, const char *to_name __unused, size_t to_len,
|
||||||
char **dresp)
|
char **dresp)
|
||||||
{
|
{
|
||||||
unsigned char *p, *q;
|
char *p, *q;
|
||||||
int rv;
|
int rv;
|
||||||
int done_compare;
|
int done_compare;
|
||||||
DIGEST_CTX ctx;
|
DIGEST_CTX ctx;
|
||||||
@ -1018,11 +1013,11 @@ compare(int from_fd, const char *from_name __unused, size_t from_len,
|
|||||||
if (trymmap(from_fd) && trymmap(to_fd)) {
|
if (trymmap(from_fd) && trymmap(to_fd)) {
|
||||||
p = mmap(NULL, from_len, PROT_READ, MAP_SHARED,
|
p = mmap(NULL, from_len, PROT_READ, MAP_SHARED,
|
||||||
from_fd, (off_t)0);
|
from_fd, (off_t)0);
|
||||||
if (p == (unsigned char *)MAP_FAILED)
|
if (p == MAP_FAILED)
|
||||||
goto out;
|
goto out;
|
||||||
q = mmap(NULL, from_len, PROT_READ, MAP_SHARED,
|
q = mmap(NULL, from_len, PROT_READ, MAP_SHARED,
|
||||||
to_fd, (off_t)0);
|
to_fd, (off_t)0);
|
||||||
if (q == (unsigned char *)MAP_FAILED) {
|
if (q == MAP_FAILED) {
|
||||||
munmap(p, from_len);
|
munmap(p, from_len);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -1036,7 +1031,7 @@ compare(int from_fd, const char *from_name __unused, size_t from_len,
|
|||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
if (!done_compare) {
|
if (!done_compare) {
|
||||||
unsigned char buf1[MAXBSIZE];
|
char buf1[MAXBSIZE];
|
||||||
char buf2[MAXBSIZE];
|
char buf2[MAXBSIZE];
|
||||||
int n1, n2;
|
int n1, n2;
|
||||||
|
|
||||||
@ -1146,8 +1141,8 @@ copy(int from_fd, const char *from_name, int to_fd, const char *to_name,
|
|||||||
{
|
{
|
||||||
int nr, nw;
|
int nr, nw;
|
||||||
int serrno;
|
int serrno;
|
||||||
unsigned char *p;
|
char *p;
|
||||||
unsigned char buf[MAXBSIZE];
|
char buf[MAXBSIZE];
|
||||||
int done_copy;
|
int done_copy;
|
||||||
DIGEST_CTX ctx;
|
DIGEST_CTX ctx;
|
||||||
|
|
||||||
@ -1167,7 +1162,7 @@ copy(int from_fd, const char *from_name, int to_fd, const char *to_name,
|
|||||||
done_copy = 0;
|
done_copy = 0;
|
||||||
if (size <= 8 * 1048576 && trymmap(from_fd) &&
|
if (size <= 8 * 1048576 && trymmap(from_fd) &&
|
||||||
(p = mmap(NULL, (size_t)size, PROT_READ, MAP_SHARED,
|
(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);
|
nw = write(to_fd, p, size);
|
||||||
if (nw != size) {
|
if (nw != size) {
|
||||||
serrno = errno;
|
serrno = errno;
|
||||||
|
Loading…
Reference in New Issue
Block a user