Merge pull request #2020 from zxlhhyccc/update

shadowsocksr-libev: Fix bug.
This commit is contained in:
zxl hhyccc authored and GitHub committed 2026-07-04 00:07:48 +08:00
commit 9ae99b8772
2 files changed
+54

No files matched your search

@@ -0,0 +1,21 @@
--- a/libev/ev.c
+++ b/libev/ev.c
@@ -1946,7 +1946,7 @@ static void * noinline ecb_cold
array_realloc (int elem, void *base, int *cur, int cnt)
{
*cur = array_nextsize (elem, *cur, cnt);
- return ev_realloc (base, elem * *cur);
+ return ev_realloc (base, (size_t)elem * (size_t)*cur);
}
#define array_init_zero(base,count) \
@@ -4252,7 +4252,8 @@ infy_add (EV_P_ ev_stat *w)
if ((errno == ENOENT || errno == EACCES) && strlen (w->path) < 4096)
{
char path [4096];
- strcpy (path, w->path);
+ strncpy (path, w->path, sizeof (path) - 1);
+ path [sizeof (path) - 1] = 0;
do
{
@@ -0,0 +1,33 @@
--- a/server/encrypt.c
+++ b/server/encrypt.c
@@ -320,8 +320,8 @@ static void
merge(uint8_t *left, int llength, uint8_t *right,
int rlength, uint32_t salt, uint64_t key)
{
- uint8_t *ltmp = (uint8_t *)malloc(llength * sizeof(uint8_t));
- uint8_t *rtmp = (uint8_t *)malloc(rlength * sizeof(uint8_t));
+ uint8_t *ltmp = (uint8_t *)malloc(llength);
+ uint8_t *rtmp = (uint8_t *)malloc(rlength);
uint8_t *ll = ltmp;
uint8_t *rr = rtmp;
@@ -783,7 +783,7 @@ cipher_context_set_iv(cipher_ctx_t *ctx,
}
if (!enc) {
- memcpy(ctx->iv, iv, iv_len);
+ memcpy(ctx->iv, iv, min(iv_len, MAX_IV_LENGTH));
}
if (enc_method >= SALSA20) {
@@ -803,8 +803,8 @@ cipher_context_set_iv(cipher_ctx_t *ctx,
#ifdef USE_CRYPTO_APPLECC
cipher_cc_t *cc = &ctx->cc;
if (cc->valid == kCCContextValid) {
- memcpy(cc->iv, iv, iv_len);
- memcpy(cc->key, true_key, enc_key_len);
+ memcpy(cc->iv, iv, min(iv_len, MAX_IV_LENGTH));
+ memcpy(cc->key, true_key, min(enc_key_len, MAX_KEY_LENGTH));
cc->iv_len = iv_len;
cc->key_len = enc_key_len;
cc->encrypt = enc ? kCCEncrypt : kCCDecrypt;