Commit 223e6eee authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/fix-websrv' into integration_2024_w43 (!3010)

Fix heap overflow in websrv
parents 8eae2ff0 f8a51921
...@@ -268,7 +268,7 @@ The web server back-end is using the [oai configuration module](Config/Rtusage). ...@@ -268,7 +268,7 @@ The web server back-end is using the [oai configuration module](Config/Rtusage).
| `listenaddr` | `ipV4 address, ascii format` | "0.0.0.0" | local address the back-end is listening on | | `listenaddr` | `ipV4 address, ascii format` | "0.0.0.0" | local address the back-end is listening on |
| `listenport` | `integer` | 8090 | port number the server is listening on | | `listenport` | `integer` | 8090 | port number the server is listening on |
| debug | `integer` | 0 | When not 0, http requests headers and json objects dump are added to back-end traces | | debug | `integer` | 0 | When not 0, http requests headers and json objects dump are added to back-end traces |
| fpath | character string | websrv | The path to on-disk http server resources . The default value matches the front-end installation when running the softmodem from the executables repository. | | fpath | character string | common/utils/websrv | The path to on-disk http server resources . The default value matches the front-end installation when running the softmodem from the executables repository. |
| cert, key, rootca | `character string` | null | certificates and key used to trigger https protocol (not tested) | | cert, key, rootca | `character string` | null | certificates and key used to trigger https protocol (not tested) |
| | | | | | | | | |
......
...@@ -56,7 +56,7 @@ paramdef_t websrvoptions[] = { ...@@ -56,7 +56,7 @@ paramdef_t websrvoptions[] = {
{"listenport", "<local port>\n", 0, uptr : &(websrvparams.listenport), defuintval : 8090, TYPE_UINT, 0}, {"listenport", "<local port>\n", 0, uptr : &(websrvparams.listenport), defuintval : 8090, TYPE_UINT, 0},
{"priority", "<scheduling policy (0-99)\n", 0, iptr : &websrvparams.priority, defuintval : 0, TYPE_INT, 0}, {"priority", "<scheduling policy (0-99)\n", 0, iptr : &websrvparams.priority, defuintval : 0, TYPE_INT, 0},
{"debug", "<debug level>\n", 0, uptr : &websrvparams.dbglvl, defuintval : 0, TYPE_UINT, 0}, {"debug", "<debug level>\n", 0, uptr : &websrvparams.dbglvl, defuintval : 0, TYPE_UINT, 0},
{"fpath", "<file directory>\n", 0, strptr : &websrvparams.fpath, defstrval : "websrv", TYPE_STRING, 0}, {"fpath", "<file directory>\n", 0, strptr : &websrvparams.fpath, defstrval : "common/utils/websrv", TYPE_STRING, 0},
{"cert", "<cert file>\n", 0, strptr : &websrvparams.certfile, defstrval : NULL, TYPE_STRING, 0}, {"cert", "<cert file>\n", 0, strptr : &websrvparams.certfile, defstrval : NULL, TYPE_STRING, 0},
{"key", "<key file>\n", 0, strptr : &websrvparams.keyfile, defstrval : NULL, TYPE_STRING, 0}, {"key", "<key file>\n", 0, strptr : &websrvparams.keyfile, defstrval : NULL, TYPE_STRING, 0},
{"rootca", "<root ca file>\n", 0, strptr : &websrvparams.rootcafile, defstrval : NULL, TYPE_STRING, 0}, {"rootca", "<root ca file>\n", 0, strptr : &websrvparams.rootcafile, defstrval : NULL, TYPE_STRING, 0},
...@@ -267,7 +267,7 @@ int websrv_callback_get_softmodemhelp(const struct _u_request *request, struct _ ...@@ -267,7 +267,7 @@ int websrv_callback_get_softmodemhelp(const struct _u_request *request, struct _
int httpstatus = 204; // no content int httpstatus = 204; // no content
char *hlpfile = strstr(request->http_url, "helpfiles"); char *hlpfile = strstr(request->http_url, "helpfiles");
if (hlpfile != NULL) { if (hlpfile != NULL) {
char *hlppath = malloc(strlen(hlpfile) + strlen(websrvparams.fpath) + 1); char *hlppath = malloc(strlen(hlpfile) + strlen(websrvparams.fpath) + 2);
sprintf(hlppath, "%s/%s", websrvparams.fpath, hlpfile); sprintf(hlppath, "%s/%s", websrvparams.fpath, hlpfile);
help_string = websrv_read_file(hlppath); help_string = websrv_read_file(hlppath);
if (help_string == NULL) { if (help_string == NULL) {
...@@ -291,9 +291,10 @@ int websrv_callback_default(const struct _u_request *request, struct _u_response ...@@ -291,9 +291,10 @@ int websrv_callback_default(const struct _u_request *request, struct _u_response
LOG_I(UTIL, "[websrv] Requested file is: %s %s\n", request->http_verb, request->http_url); LOG_I(UTIL, "[websrv] Requested file is: %s %s\n", request->http_verb, request->http_url);
websrv_dump_request("default ", request, websrvparams.dbglvl); websrv_dump_request("default ", request, websrvparams.dbglvl);
char *fpath = malloc(strlen(request->http_url) + strlen(websrvparams.fpath) + 2); const char *index_file_name = "index.html";
char *fpath = malloc(strlen(request->http_url) + strlen(websrvparams.fpath) + strlen(index_file_name) + 2);
if ((strcmp(request->http_url + 1, websrvparams.fpath) == 0) || (strcmp(request->http_url, "/") == 0)) { if ((strcmp(request->http_url + 1, websrvparams.fpath) == 0) || (strcmp(request->http_url, "/") == 0)) {
sprintf(fpath, "%s/index.html", websrvparams.fpath); sprintf(fpath, "%s/%s", websrvparams.fpath, index_file_name);
} else { } else {
sprintf(fpath, "%s/%s", websrvparams.fpath, request->http_url); sprintf(fpath, "%s/%s", websrvparams.fpath, request->http_url);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment