Skip to content
This repository has been archived by the owner on Feb 20, 2021. It is now read-only.

Fixes client buffer size underflow #546

Open
wants to merge 2 commits into
base: 3.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions deps/linenoise/linenoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@
#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include "linenoise.h"

#define LINENOISE_DEFAULT_HISTORY_MAX_LEN 100
Expand Down Expand Up @@ -1336,14 +1334,22 @@ int linenoiseHistorySetMaxLen(int len) {
/* Save the history in the specified file. On success 0 is returned
* otherwise -1 is returned. */
int linenoiseHistorySave(const char *filename) {
#ifndef _WIN32
mode_t old_umask = umask(S_IXUSR|S_IRWXG|S_IRWXO);
#endif
FILE *fp;
int j;

#ifdef _WIN32
fp = fopen(filename,"wb");
#else
fp = fopen(filename,"w");
umask(old_umask);
#endif
if (fp == NULL) return -1;
#ifndef _WIN32
chmod(filename,S_IRUSR|S_IWUSR);
#endif
for (j = 0; j < history_len; j++)
fprintf(fp,"%s\n",history[j]);
fclose(fp);
Expand Down
5 changes: 5 additions & 0 deletions src/debugmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
*/

#include <stdio.h>

#ifdef _WIN32
#define __func__ __FUNCTION__
#endif

#define D(...) \
do { \
FILE *fp = fopen("/tmp/log.txt","a"); \
Expand Down
2 changes: 1 addition & 1 deletion src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ int writeToClient(int fd, client *c, int handler_installed) {
} else {
o = listNodeValue(ln);
objlen = (int)sdslen(o->ptr);
objmem = sdsZmallocSize(o->ptr);
objmem = getStringObjectSdsUsedMemory(o);

if (objlen == 0) {
listDelNode(c->reply,ln);
Expand Down
7 changes: 5 additions & 2 deletions src/redis-check-rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,14 @@ void rdbCheckSetError(const char *fmt, ...) {
/* During RDB check we setup a special signal handler for memory violations
* and similar conditions, so that we can log the offending part of the RDB
* if the crash is due to broken content. */
#ifdef _WIN32
void rdbCheckHandleCrash(int sig) {
#else
void rdbCheckHandleCrash(int sig, siginfo_t *info, void *secret) {
UNUSED(sig);
UNUSED(info);
UNUSED(secret);

#endif
UNUSED(sig);
rdbCheckError("Server crash checking the specified RDB file!");
exit(1);
}
Expand Down