mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-29 13:52:17 +00:00
msvc: Fix some -W4 warnings
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
This commit is contained in:
parent
1a7bae4d0f
commit
e8a952561c
@ -9,7 +9,8 @@
|
|||||||
* Nicolas Pitre <nico@cam.org>.
|
* Nicolas Pitre <nico@cam.org>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static size_t hdr_sz(
|
static int hdr_sz(
|
||||||
|
size_t *size,
|
||||||
const unsigned char **delta,
|
const unsigned char **delta,
|
||||||
const unsigned char *end)
|
const unsigned char *end)
|
||||||
{
|
{
|
||||||
@ -25,7 +26,8 @@ static size_t hdr_sz(
|
|||||||
shift += 7;
|
shift += 7;
|
||||||
} while (c & 0x80);
|
} while (c & 0x80);
|
||||||
*delta = d;
|
*delta = d;
|
||||||
return r;
|
*size = r;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int git__delta_apply(
|
int git__delta_apply(
|
||||||
@ -36,17 +38,19 @@ int git__delta_apply(
|
|||||||
size_t delta_len)
|
size_t delta_len)
|
||||||
{
|
{
|
||||||
const unsigned char *delta_end = delta + delta_len;
|
const unsigned char *delta_end = delta + delta_len;
|
||||||
size_t res_sz;
|
size_t base_sz, res_sz;
|
||||||
unsigned char *res_dp;
|
unsigned char *res_dp;
|
||||||
|
|
||||||
/* Check that the base size matches the data we were given;
|
/* Check that the base size matches the data we were given;
|
||||||
* if not we would underflow while accessing data from the
|
* if not we would underflow while accessing data from the
|
||||||
* base object, resulting in data corruption or segfault.
|
* base object, resulting in data corruption or segfault.
|
||||||
*/
|
*/
|
||||||
if (base_len != hdr_sz(&delta, delta_end))
|
if ((hdr_sz(&base_sz, &delta, delta_end) < 0) || (base_sz != base_len))
|
||||||
|
return GIT_ERROR;
|
||||||
|
|
||||||
|
if (hdr_sz(&res_sz, &delta, delta_end) < 0)
|
||||||
return GIT_ERROR;
|
return GIT_ERROR;
|
||||||
|
|
||||||
res_sz = hdr_sz(&delta, delta_end);
|
|
||||||
if ((res_dp = git__malloc(res_sz + 1)) == NULL)
|
if ((res_dp = git__malloc(res_sz + 1)) == NULL)
|
||||||
return GIT_ERROR;
|
return GIT_ERROR;
|
||||||
res_dp[res_sz] = '\0';
|
res_dp[res_sz] = '\0';
|
||||||
|
@ -209,7 +209,6 @@ int gitfo_write_cached(gitfo_cache *ioc, void *buff, size_t len)
|
|||||||
if (len > ioc->cache_size)
|
if (len > ioc->cache_size)
|
||||||
return gitfo_write(ioc->fd, buf, len);
|
return gitfo_write(ioc->fd, buf, len);
|
||||||
}
|
}
|
||||||
return GIT_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int gitfo_close_cached(gitfo_cache *ioc)
|
int gitfo_close_cached(gitfo_cache *ioc)
|
||||||
|
@ -840,6 +840,8 @@ static void packlist_dec(git_odb *db, git_packlist *pl)
|
|||||||
{
|
{
|
||||||
int need_free;
|
int need_free;
|
||||||
|
|
||||||
|
assert(db && pl);
|
||||||
|
|
||||||
gitlck_lock(&db->lock);
|
gitlck_lock(&db->lock);
|
||||||
need_free = !--pl->refcnt;
|
need_free = !--pl->refcnt;
|
||||||
gitlck_unlock(&db->lock);
|
gitlck_unlock(&db->lock);
|
||||||
|
@ -19,7 +19,7 @@ BEGIN_TEST(invalid_string_moo)
|
|||||||
must_fail(git_oid_mkstr(&out, "moo"));
|
must_fail(git_oid_mkstr(&out, "moo"));
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
static int from_hex(unsigned char i)
|
static int from_hex(unsigned int i)
|
||||||
{
|
{
|
||||||
if (i >= '0' && i <= '9')
|
if (i >= '0' && i <= '9')
|
||||||
return i - '0';
|
return i - '0';
|
||||||
@ -38,14 +38,14 @@ BEGIN_TEST(invalid_string_all_chars)
|
|||||||
0xb7, 0x75, 0x21, 0x3c, 0x23,
|
0xb7, 0x75, 0x21, 0x3c, 0x23,
|
||||||
0xa8, 0xbd, 0x74, 0xf5, 0xe0,
|
0xa8, 0xbd, 0x74, 0xf5, 0xe0,
|
||||||
};
|
};
|
||||||
char in[41] = "16a67770b7d8d72317c4b775213c23a8bd74f5e0\0";
|
char in[41] = "16a67770b7d8d72317c4b775213c23a8bd74f5e0";
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
in[38] = (char)i;
|
in[38] = (char)i;
|
||||||
|
|
||||||
if (from_hex(i) >= 0) {
|
if (from_hex(i) >= 0) {
|
||||||
exp[19] = (from_hex(i) << 4);
|
exp[19] = (unsigned char)(from_hex(i) << 4);
|
||||||
if (git_oid_mkstr(&out, in))
|
if (git_oid_mkstr(&out, in))
|
||||||
test_die("line %d: must accept '%s'", __LINE__, in);
|
test_die("line %d: must accept '%s'", __LINE__, in);
|
||||||
if (memcmp(out.id, exp, sizeof(out.id)))
|
if (memcmp(out.id, exp, sizeof(out.id)))
|
||||||
|
Loading…
Reference in New Issue
Block a user