From d6ac8bf23fa40721ac691cf134bb8ae80e7ff539 Mon Sep 17 00:00:00 2001 From: nishi Date: Mon, 22 Jan 2024 03:06:37 +0000 Subject: [PATCH] security patch git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@50 d27a3e52-49c5-7645-884c-6793ebffc270 --- Library/File.c | 6 +++++- Library/HTTP.c | 5 ++++- W3Version.h.p | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Library/File.c b/Library/File.c index 29a6b33..be0e9f6 100644 --- a/Library/File.c +++ b/Library/File.c @@ -6,6 +6,7 @@ #include #include +#include #include void __W3_File_Request(struct W3* w3){ @@ -29,7 +30,10 @@ void __W3_File_Request(struct W3* w3){ void* funcptr = __W3_Get_Event(w3, "data"); if(funcptr != NULL){ void(*func)(struct W3*, char*, size_t) = (void(*)(struct W3*, char*, size_t))funcptr; - func(w3, buf, len); + char* buffer = malloc(len); + memcpy(buffer, buf, len); + func(w3, buffer, len); + free(buffer); } if(feof(f)) break; } diff --git a/Library/HTTP.c b/Library/HTTP.c index 1795aff..3d722b5 100644 --- a/Library/HTTP.c +++ b/Library/HTTP.c @@ -160,7 +160,10 @@ void __W3_HTTP_Request(struct W3* w3){ void* funcptr = __W3_Get_Event(w3, "data"); if(funcptr != NULL){ void(*func)(struct W3* w3, char*, size_t) = (void(*)(struct W3* w3, char*, size_t))funcptr; - func(w3, buf + i, l - i); + char* buffer = malloc(l - i); + memcpy(buffer, buf + i, l - i); + func(w3, buffer, l - i); + free(buffer); } break; } diff --git a/W3Version.h.p b/W3Version.h.p index 70a6689..d454196 100644 --- a/W3Version.h.p +++ b/W3Version.h.p @@ -6,7 +6,7 @@ extern "C" { #endif -#define LIBW3_VERSION "1.2A" \ +#define LIBW3_VERSION "1.2B" \ SUFFIX #ifdef __cplusplus -- 2.43.0