Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
dd35581665
!36 [sync] PR-35: 回合上游补丁,数量:3个
From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
2024-08-13 08:16:05 +00:00
zhangxingrong
606ca76892 add some upstream patchs
(cherry picked from commit 3ea9b8da7821fd4eb273a89893a9e4a81d1d9358)
2024-08-13 15:43:05 +08:00
openeuler-ci-bot
c41f69ee07
!33 Update to version 1.2.0
From: @wang--ge 
Reviewed-by: @caodongxia 
Signed-off-by: @caodongxia
2023-08-22 07:51:59 +00:00
wang--ge
aa5aa6478b update to version 1.2.0 2023-08-22 10:08:50 +08:00
openeuler-ci-bot
9083e7c6fc
!32 Update package to version 1.1.0
From: @lingjuer 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
2023-07-27 01:11:57 +00:00
lingjuer
0670a4d115 Update to version 1.1.0 2023-07-20 10:20:16 +08:00
openeuler-ci-bot
c26bc56ab8
!30 [sync] PR-28: 修复fuzz测试中遇到内存未做初始化的错误
From: @openeuler-sync-bot 
Reviewed-by: @caodongxia 
Signed-off-by: @caodongxia
2023-03-13 08:08:54 +00:00
cherry530
8b56abe8f7 fix memory uninitialized in fuzz testcase
Signed-off-by: cherry530 <xuping33@huawei.com>
(cherry picked from commit 58b1cf8b9b35faf706e430d96c85e9e8f1701baa)
2023-03-13 15:50:45 +08:00
openeuler-ci-bot
42a7dcab7a
!16 fix spec changelog date
From: @loong-C 
Reviewed-by: @overweight 
Signed-off-by: @overweight
2022-05-30 11:28:02 +00:00
loong_C
3f04d5a1eb fix spec changelog date 2022-05-24 14:50:11 +08:00
8 changed files with 211 additions and 32 deletions

View File

@ -0,0 +1,32 @@
From f8dfdfbe051a678d8373fe286e736652060dc492 Mon Sep 17 00:00:00 2001
From: michael-grunder <michael.grunder@gmail.com>
Date: Tue, 25 Jul 2023 10:38:00 -0700
Subject: [PATCH] Document poll(2) logic changes.
See #1206, #1213
---
README.md | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/README.md b/README.md
index 74364b411..c0fc2a1cc 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,17 @@ Redis version >= 1.2.0.
The library comes with multiple APIs. There is the
*synchronous API*, the *asynchronous API* and the *reply parsing API*.
+## Upgrading to > 1.2.0 (**PRERELEASE**)
+
+* After v1.2.0 we modified how we invoke `poll(2)` to wait for connections to complete, such that we will now retry
+ the call if it is interrupted by a signal until:
+
+ a) The connection succeeds or fails.
+ b) The overall connection timeout is reached.
+
+ In previous versions, an interrupted `poll(2)` call would cause the connection to fail
+ with `c->err` set to `REDIS_ERR_IO` and `c->errstr` set to `poll(2): Interrupted system call`.
+
## Upgrading to `1.1.0`
Almost all users will simply need to recompile their applications against the newer version of hiredis.

24
Fix-memory-leak.patch Normal file
View File

@ -0,0 +1,24 @@
From 0084435a5fdfdd478bae1d2118bfd0ed37851ace Mon Sep 17 00:00:00 2001
From: Mark Agranat <agranatmarkit@gmail.com>
Date: Tue, 14 Nov 2023 23:53:25 +0100
Subject: [PATCH] Fix memory leak.
When redisLibuvAttach receives error from call to
uv_poll_init_socket there is a memory leaked ptr
of type redisLibuvEvents.
---
adapters/libuv.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/adapters/libuv.h b/adapters/libuv.h
index 268edab79..ec67c15a2 100644
--- a/adapters/libuv.h
+++ b/adapters/libuv.h
@@ -159,6 +159,7 @@ static int redisLibuvAttach(redisAsyncContext* ac, uv_loop_t* loop) {
memset(p, 0, sizeof(*p));
if (uv_poll_init_socket(loop, &p->handle, c->fd) != 0) {
+ hi_free(p);
return REDIS_ERR;
}

View File

@ -0,0 +1,101 @@
From 97679e57badd4df954e083f4aa5408d29b39785f Mon Sep 17 00:00:00 2001
From: michael-grunder <michael.grunder@gmail.com>
Date: Wed, 12 Jul 2023 14:23:07 -0700
Subject: [PATCH] Retry poll(2) if we are intterupted.
This commit adds logic to retry our poll call when waiting for the
connection to complete, in the event that we are interrupted by a
signal.
Additionally we do some simple bookkeeping to keep track of the overall
timeout specified by the user.
Fixes #1206
---
net.c | 52 +++++++++++++++++++++++++++++++++++-----------------
1 file changed, 35 insertions(+), 17 deletions(-)
diff --git a/net.c b/net.c
index 1e016384f..c7d827139 100644
--- a/net.c
+++ b/net.c
@@ -41,6 +41,7 @@
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
+#include <time.h>
#include "net.h"
#include "sds.h"
@@ -271,37 +272,54 @@ static int redisContextTimeoutMsec(redisContext *c, long *result)
return REDIS_OK;
}
+static long redisPollMillis(void) {
+#ifndef _MSC_VER
+ struct timespec now;
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ return (now.tv_sec * 1000) + now.tv_nsec / 1000000;
+#else
+ FILETIME ft;
+ GetSystemTimeAsFileTime(&ft);
+ return (((long long)ft.dwHighDateTime << 32) | ft.dwLowDateTime) / 10;
+#endif
+}
+
static int redisContextWaitReady(redisContext *c, long msec) {
- struct pollfd wfd[1];
+ struct pollfd wfd;
+ long end;
+ int res;
- wfd[0].fd = c->fd;
- wfd[0].events = POLLOUT;
+ if (errno != EINPROGRESS) {
+ __redisSetErrorFromErrno(c,REDIS_ERR_IO,NULL);
+ redisNetClose(c);
+ return REDIS_ERR;
+ }
- if (errno == EINPROGRESS) {
- int res;
+ wfd.fd = c->fd;
+ wfd.events = POLLOUT;
+ end = msec >= 0 ? redisPollMillis() + msec : 0;
- if ((res = poll(wfd, 1, msec)) == -1) {
+ while ((res = poll(&wfd, 1, msec)) <= 0) {
+ if (res < 0 && errno != EINTR) {
__redisSetErrorFromErrno(c, REDIS_ERR_IO, "poll(2)");
redisNetClose(c);
return REDIS_ERR;
- } else if (res == 0) {
+ } else if (res == 0 || (msec >= 0 && redisPollMillis() >= end)) {
errno = ETIMEDOUT;
- __redisSetErrorFromErrno(c,REDIS_ERR_IO,NULL);
+ __redisSetErrorFromErrno(c, REDIS_ERR_IO, NULL);
redisNetClose(c);
return REDIS_ERR;
+ } else {
+ /* res < 0 && errno == EINTR, try again */
}
+ }
- if (redisCheckConnectDone(c, &res) != REDIS_OK || res == 0) {
- redisCheckSocketError(c);
- return REDIS_ERR;
- }
-
- return REDIS_OK;
+ if (redisCheckConnectDone(c, &res) != REDIS_OK || res == 0) {
+ redisCheckSocketError(c);
+ return REDIS_ERR;
}
- __redisSetErrorFromErrno(c,REDIS_ERR_IO,NULL);
- redisNetClose(c);
- return REDIS_ERR;
+ return REDIS_OK;
}
int redisCheckConnectDone(redisContext *c, int *completed) {

View File

@ -1,26 +0,0 @@
From 78a8af37c6fc43e5fe4487a7a0762c9473444e37 Mon Sep 17 00:00:00 2001
From: lingsheng <lingsheng@huawei.com>
Date: Fri, 4 Jun 2021 11:05:20 +0800
Subject: [PATCH] fix heap buffer overflow in redisvFormatCommand
---
hiredis.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/hiredis.c b/hiredis.c
index 73d0251..af3a079 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -375,6 +375,9 @@ int redisvFormatCommand(char **target, const char *format, va_list ap) {
touched = 1;
c++;
+ if (*c == '\0') {
+ goto format_err;
+ }
}
c++;
}
--
2.23.0

View File

@ -0,0 +1,24 @@
From 28b80dc9143d3625b05e28debe77368d332e9bf6 Mon Sep 17 00:00:00 2001
Date: Tue, 22 Aug 2023 09:39:36 +0800
Subject: [PATCH] fix memory uninitialized in fuzz testcase
---
sds.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sds.c b/sds.c
index 21ecec0..8d0ec69 100644
--- a/sds.c
+++ b/sds.c
@@ -516,7 +516,7 @@ sds sdscatvprintf(sds s, const char *fmt, va_list ap) {
} else {
buflen = sizeof(staticbuf);
}
-
+ memset(buf, 0, buflen);
/* Try with buffers two times bigger every time we fail to
* fit the string in the current buffer size. */
while(1) {
--
2.33.0

BIN
hiredis-1.2.0.tar.gz Normal file

Binary file not shown.

View File

@ -1,13 +1,19 @@
Name: hiredis
Version: 1.0.2
Release: 1
Version: 1.2.0
Release: 2
Summary: A minimalistic C client library for the Redis database
License: BSD
URL: https://github.com/redis/hiredis
Source0: https://github.com/redis/hiredis/archive/refs/tags/v%{version}.tar.gz
Source0: https://github.com/redis/hiredis/archive/refs/tags/v%{version}.tar.gz#/hiredis-1.2.0.tar.gz
BuildRequires: gcc redis
Patch0001: fix-heap-buffer-overflow-in-redisvFormatCommand.patch
Patch0002: fix-memory-uninitialized-in-fuzz-testcase.patch
Patch0003: Retry-poll-2-if-we-are-intterupted.patch
Patch0004: Document-poll-2-logic-changes.patch
Patch0005: Fix-memory-leak.patch
%description
Hiredis is a minimalistic C client library for the Redis database.
@ -27,7 +33,7 @@ Requires: hiredis = %{version}-%{release}
The hiredis-devel package contains development files to build applications for hiredis.
%prep
%autosetup -p1
%autosetup -p1
%build
%make_build PREFIX="%{_prefix}" LIBRARY_PATH="%{_lib}" DEBUG="%{optflags}" LDFLAGS="%{?__global_ldflags}"
@ -60,13 +66,31 @@ make check || true
%{_libdir}/pkgconfig/hiredis.pc
%changelog
* Wed Aug 7 2024 zhangxingrong <zhangxingrong@uniontech.cn> - 1.2.0-2
- Retry poll(2) if we are intterupted
- Document poll(2) logic changes
- Fix memory leak
* Tue Aug 22 2023 Ge Wang <wang__ge@126.com> - 1.2.0-1
- Update to version 1.2.0
* Thu Jul 20 2023 zhangchenglin <zhangchenglin@kylinos.cn> - 1.1.0-1
- Update to version 1.1.0
* Fri Dec 16 2022 xu_ping <xuping33@h-partners.com> - 1.0.2-3
- fix memory uninitialized in fuzz testcase
* Tue May 24 2022 loong_C <loong_c@yeah.net> - 1.0.2-2
- fix spec changelog date
* Mon Oct 11 2021 houyingchao<houyingchao@huawei.com> - 1.0.2-1
- Fix CVE-2021-32765
* Fri Jun 4 2021 lingsheng<lingsheng@huawei.com> - 0.13.3-12
- fix heap buffer overflow in redisvFormatCommand
* Thu Mar 17 2020 likexin<likexin4@huawei.com> - 0.13.3-11
* Tue Mar 17 2020 likexin<likexin4@huawei.com> - 0.13.3-11
- fix up cve-2020-7105
* Tue Dec 31 2019 liujing<liujing144@huawei.com> - 0.13.3-10

Binary file not shown.