mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-22 11:36:21 +00:00
Fix overflow in rx_icmp
This commit is contained in:
1 parent
a88a11c243
commit
9680b8ccb3
6 files changed
+34
-18
No files matched your search
+3
-3
@@ -1,5 +1,5 @@
|
||||
#include "base64.h"
|
||||
#include "arch.h"
|
||||
#include "base64.h"
|
||||
|
||||
static int mg_b64idx(int c) {
|
||||
if (c < 26) {
|
||||
@@ -66,9 +66,9 @@ int mg_base64_encode(const unsigned char *p, int n, char *to) {
|
||||
}
|
||||
|
||||
int mg_base64_decode(const char *src, int n, char *dst) {
|
||||
const char *end = src + n;
|
||||
const char *end = src == NULL ? NULL : src + n; // Cannot add to NULL
|
||||
int len = 0;
|
||||
while (src + 3 < end) {
|
||||
while (src != NULL && src + 3 < end) {
|
||||
int a = mg_b64rev(src[0]), b = mg_b64rev(src[1]), c = mg_b64rev(src[2]),
|
||||
d = mg_b64rev(src[3]);
|
||||
if (a == 64 || a < 0 || b == 64 || b < 0 || c < 0 || d < 0) return 0;
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
#include "http.h"
|
||||
#include "arch.h"
|
||||
#include "base64.h"
|
||||
#include "fmt.h"
|
||||
#include "http.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
#include "ssi.h"
|
||||
@@ -202,7 +202,7 @@ static void mg_http_parse_headers(const char *s, const char *end,
|
||||
|
||||
int mg_http_parse(const char *s, size_t len, struct mg_http_message *hm) {
|
||||
int is_response, req_len = mg_http_get_request_len((unsigned char *) s, len);
|
||||
const char *end = s + req_len, *qs;
|
||||
const char *end = s == NULL ? NULL : s + req_len, *qs; // Cannot add to NULL
|
||||
struct mg_str *cl;
|
||||
|
||||
memset(hm, 0, sizeof(*hm));
|
||||
@@ -562,12 +562,12 @@ static void printdirentry(const char *name, void *userdata) {
|
||||
}
|
||||
#if defined(MG_HTTP_DIRLIST_TIME)
|
||||
char time_str[30];
|
||||
struct tm * time_info = localtime(&t);
|
||||
struct tm *time_info = localtime(&t);
|
||||
strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info);
|
||||
mg_snprintf(mod, sizeof(mod), "%s", time_str);
|
||||
#elif defined(MG_HTTP_DIRLIST_TIME_UTC)
|
||||
char time_str[30];
|
||||
struct tm * time_info = gmtime(&t);
|
||||
struct tm *time_info = gmtime(&t);
|
||||
strftime(time_str, sizeof time_str, "%Y/%m/%d %H:%M:%S", time_info);
|
||||
mg_snprintf(mod, sizeof(mod), "%s", time_str);
|
||||
#else
|
||||
|
||||
Reference in new issue
Block a user