diff options
| author | Dave Hibberd <hibby@debian.org> | 2026-06-29 11:36:57 +0100 |
|---|---|---|
| committer | Dave Hibberd <hibby@debian.org> | 2026-06-29 11:36:57 +0100 |
| commit | 23de03a0c8bf8a564cc0442f49d050ed11e372b8 (patch) | |
| tree | 7cc837d9215b6e427db85c443d0ea1f6874e2aa0 /WebMail.c | |
| parent | 7aa6cec9300c8a3e9ef98b19791ad324d487512e (diff) | |
New upstream version 6.0.25.33.1+repackupstream/6.0.25.33.1+repack
Diffstat (limited to 'WebMail.c')
| -rw-r--r-- | WebMail.c | 49 |
1 files changed, 44 insertions, 5 deletions
@@ -27,6 +27,7 @@ along with LinBPQ/BPQ32. If not, see http://www.gnu.org/licenses #ifdef WIN32
//#include "C:\Program Files (x86)\GnuWin32\include\iconv.h"
+ #define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
#else
#include <iconv.h>
#include <dirent.h>
@@ -1467,6 +1468,15 @@ void ProcessWebMailMessage(struct HTTPConnectionInfo * Session, char * Key, BOOL char Type[64] = "Content-Type: text/html\r\n";
UndoTransparency(FN);
+
+ // protect against malicious access
+
+ if (strstr(FN, ".."))
+ {
+ *RLen = sprintf(Reply, "HTTP/1.1 404 Not Found\r\nContent-Length: 16\r\n\r\nPage not found\r\n");
+ return;
+ }
+
ext = strchr(FN, '.');
sprintf(MsgFile, "%s/%s", BPQDirectory, FN);
@@ -1480,6 +1490,14 @@ void ProcessWebMailMessage(struct HTTPConnectionInfo * Session, char * Key, BOOL return;
}
+ FileSize = STAT.st_size;
+
+ if (FileSize > 200000)
+ {
+ *RLen = sprintf(Reply, "HTTP/1.1 400 File too long\r\nContent-Length: 15\r\n\r\nFile too long\r\n");
+ return;
+ }
+
hFile = fopen(MsgFile, "rb");
if (hFile == 0)
@@ -1488,7 +1506,7 @@ void ProcessWebMailMessage(struct HTTPConnectionInfo * Session, char * Key, BOOL return;
}
- FileSize = STAT.st_size;
+
MsgBytes = malloc(FileSize + 1);
ReadLen = fread(MsgBytes, 1, FileSize, hFile);
@@ -1543,8 +1561,24 @@ void ProcessWebMailMessage(struct HTTPConnectionInfo * Session, char * Key, BOOL char * ext;
char Type[64] = "Content-Type: text/html\r\n";
-
UndoTransparency(FN);
+
+ // protect against malicious access
+
+ if (strstr(FN, ".."))
+ {
+ *RLen = sprintf(Reply, "HTTP/1.1 404 Not Found\r\nContent-Length: 16\r\n\r\nPage not found\r\n");
+ return;
+ }
+
+ // I'm pretty sure this should only be used for form sets, so name should start Standard or Local
+
+ if (_memicmp(FN, "Local", 5) != 0 && (_memicmp(FN, "Standard", 9) != 0))
+ {
+ *RLen = sprintf(Reply, "HTTP/1.1 404 Not Found\r\nContent-Length: 16\r\n\r\nPage not found\r\n");
+ return;
+ }
+
ext = strchr(FN, '.');
sprintf(MsgFile, "%s/%s", BPQDirectory, FN);
@@ -1558,6 +1592,14 @@ void ProcessWebMailMessage(struct HTTPConnectionInfo * Session, char * Key, BOOL return;
}
+ FileSize = STAT.st_size;
+
+ if (FileSize > 200000)
+ {
+ *RLen = sprintf(Reply, "HTTP/1.1 400 File too big\r\nContent-Length: 15\r\n\r\nFile too long\r\n");
+ return;
+ }
+
hFile = fopen(MsgFile, "rb");
if (hFile == 0)
@@ -1566,7 +1608,6 @@ void ProcessWebMailMessage(struct HTTPConnectionInfo * Session, char * Key, BOOL return;
}
- FileSize = STAT.st_size;
MsgBytes = malloc(FileSize + 1);
ReadLen = fread(MsgBytes, 1, FileSize, hFile);
@@ -3534,8 +3575,6 @@ int DisplayWebForm(struct HTTPConnectionInfo * Session, struct MsgInfo * Msg, ch sprintf(FormDir, "WMFile/%s/%s/", Dir->FormSet, Dir->DirName);
-
-
if (Form == NULL)
{
// Not found - just display as normal message
|
