2023-05-17 Fred Gleason <fredg@paravelsystems.com>

* Fixed a regression in the WebAPI that caused imports to bypass the
	maximum file size limitation set the 'System Settings' in rdadmin(1).

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2023-05-17 13:19:59 -04:00
parent 5265ffe4ca
commit 5eb1c39231
8 changed files with 37 additions and 15 deletions

View File

@@ -33,7 +33,7 @@
#include <rdformpost.h>
RDFormPost::RDFormPost(RDFormPost::Encoding encoding,unsigned maxsize,
RDFormPost::RDFormPost(RDFormPost::Encoding encoding,int64_t maxsize,
bool auto_delete)
{
bool ok=false;
@@ -70,8 +70,12 @@ RDFormPost::RDFormPost(RDFormPost::Encoding encoding,unsigned maxsize,
post_error=RDFormPost::ErrorPostTooLarge;
return;
}
post_content_length=QString(getenv("CONTENT_LENGTH")).toUInt(&ok);
if((!ok)||((maxsize>0)&&(post_content_length>maxsize))) {
post_content_length=QString(getenv("CONTENT_LENGTH")).toLongLong(&ok);
if((!ok)||(post_content_length<0)) {
post_error=RDFormPost::ErrorMalformedData;
return;
}
if((maxsize>0)&&(post_content_length>maxsize)) {
post_error=RDFormPost::ErrorPostTooLarge;
return;
}
@@ -562,7 +566,8 @@ void RDFormPost::LoadUrlEncoding(char first)
total_read+=n;
}
post_data[post_content_length]=0;
// post_data[post_content_length]=0;
post_data[total_read]=0;
lines=QString(post_data).split("&");
for(int i=0;i<lines.size();i++) {
line=lines[i].split("=",QString::KeepEmptyParts);