Skip to content

Commit

Permalink
fix: parse url crash (#340) (DSP-1247)
Browse files Browse the repository at this point in the history
  • Loading branch information
lrosenth authored Jan 22, 2021
1 parent 8c79a61 commit e710237
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions config/sipi.config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@ admin = {

fileserver = {
--
-- directory where the documents for the normal webserver are located
-- directory on disk where the documents for the normal webserver are located
--
docroot = './server',

--
-- route under which the normal webserver should respond to requests
-- URL route under which the normal webserver should respond to requests
--
wwwroute = '/server'
}
Expand Down
2 changes: 1 addition & 1 deletion server/do-upload.elua
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ end
end
for imgindex,fn in pairs(newfilename) do
server.print('<tr><td>', fn,
'</td><td><a href="', protocol, server.host, '/images/', fn, '/full/max/0/default.jpg"><img src="', protocol, server.host, '/images/', fn,'/full/,250/0/default.jpg" /></a></td></tr>')
'</td><td><a href="', protocol, server.host, '/images/', fn, '/full/max/0/default.jpg"><img src="', protocol, server.host, '/images/', fn,'/full/^,250/0/default.jpg" /></a></td></tr>')
end

</lua>
Expand Down
6 changes: 3 additions & 3 deletions shttps/Hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <sys/uio.h>
#include <unistd.h>

#include "SipiError.h"
#include "Error.h"
#include "Hash.h"
#include "makeunique.h"

Expand All @@ -44,7 +44,7 @@ namespace shttps {
Hash::Hash(HashType type) {
context = EVP_MD_CTX_create();
if (context == nullptr) {
throw Sipi::SipiError(__file__, __LINE__, "EVP_MD_CTX_create failed!");
throw Error(__file__, __LINE__, "EVP_MD_CTX_create failed!");
}
int status;
switch (type) {
Expand Down Expand Up @@ -75,7 +75,7 @@ namespace shttps {
}
if (status != 1) {
EVP_MD_CTX_destroy(context);
throw Sipi::SipiError(__file__, __LINE__, "EVP_DigestInit_ex failed!");
throw Error(__file__, __LINE__, "EVP_DigestInit_ex failed!");
}
}
//==========================================================================
Expand Down
1 change: 1 addition & 0 deletions shttps/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ namespace shttps {
RequestHandler matching_handler = nullptr;

for (item = handler[conn.method()].rbegin(); item != handler[conn.method()].rend(); ++item) {
//TODO:: Selects wrong handler if the URI starts with the substring
size_t len = conn.uri().length() < item->first.length() ? conn.uri().length() : item->first.length();

if (item->first == conn.uri().substr(0, len)) {
Expand Down
9 changes: 6 additions & 3 deletions src/formats/SipiIOJ2k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,16 @@ namespace Sipi {
int tw = 0, th = 0;
if ((params != nullptr) && (!params->empty())) {
if (params->find(J2K_Stiles) != params->end()) {
const int mindim = img->ny < img->nx ? img->ny : img->nx;
int n = std::sscanf(params->at(J2K_Stiles).c_str(), "{%d,%d}", &tw, &th);
if (n != 2) {
throw SipiImageError(__file__, __LINE__, "Tiling parameter invalid!");
}
std::stringstream ss;
ss << "Stiles=" << params->at(J2K_Stiles);
siz.parse_string(ss.str().c_str());
if ((mindim > tw) && (mindim > th)) {
std::stringstream ss;
ss << "Stiles=" << params->at(J2K_Stiles);
siz.parse_string(ss.str().c_str());
}
}
} else {
const int mindim = img->ny < img->nx ? img->ny : img->nx;
Expand Down

0 comments on commit e710237

Please sign in to comment.