Skip to content

Commit

Permalink
Fix #1453 - do not allow empty wakeup buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
cpq committed Jan 21, 2022
1 parent 59c4dfa commit e565a7e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
6 changes: 1 addition & 5 deletions mongoose.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,11 +902,7 @@ static bool p_remove(const char *path) {
}

static bool p_mkdir(const char *path) {
#if defined(__MINGW32__) || defined(__MINGW64__)
return mkdir(path) == 0;
#else
return mkdir(path, 0775) == 0;
#endif
}

#else
Expand Down Expand Up @@ -3511,7 +3507,7 @@ static bool mg_socketpair(SOCKET sp[2], union usa usa[2]) {
}

void mg_mgr_wakeup(struct mg_connection *c, const void *buf, size_t len) {
LOG(LL_INFO, ("skt: %p", c->pfn_data));
if (buf == NULL || len == 0) buf = (void *) "", len = 1;
send((SOCKET) (size_t) c->pfn_data, (const char *) buf, len, MSG_NONBLOCKING);
}

Expand Down
2 changes: 2 additions & 0 deletions mongoose.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ struct timeval {
#endif

#include <ctype.h>
#include <direct.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
Expand Down Expand Up @@ -408,6 +409,7 @@ typedef int socklen_t;

#define realpath(a, b) _fullpath((b), (a), MG_PATH_MAX)
#define sleep(x) Sleep(x)
#define mkdir(a, b) _mkdir(a)

#ifndef va_copy
#ifdef __va_copy
Expand Down
2 changes: 2 additions & 0 deletions src/arch_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#endif

#include <ctype.h>
#include <direct.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
Expand Down Expand Up @@ -70,6 +71,7 @@ typedef int socklen_t;

#define realpath(a, b) _fullpath((b), (a), MG_PATH_MAX)
#define sleep(x) Sleep(x)
#define mkdir(a, b) _mkdir(a)

#ifndef va_copy
#ifdef __va_copy
Expand Down
4 changes: 0 additions & 4 deletions src/fs_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,7 @@ static bool p_remove(const char *path) {
}

static bool p_mkdir(const char *path) {
#if defined(__MINGW32__) || defined(__MINGW64__)
return mkdir(path) == 0;
#else
return mkdir(path, 0775) == 0;
#endif
}

#else
Expand Down
2 changes: 1 addition & 1 deletion src/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ static bool mg_socketpair(SOCKET sp[2], union usa usa[2]) {
}

void mg_mgr_wakeup(struct mg_connection *c, const void *buf, size_t len) {
LOG(LL_INFO, ("skt: %p", c->pfn_data));
if (buf == NULL || len == 0) buf = (void *) "", len = 1;
send((SOCKET) (size_t) c->pfn_data, (const char *) buf, len, MSG_NONBLOCKING);
}

Expand Down

0 comments on commit e565a7e

Please sign in to comment.