summaryrefslogtreecommitdiffhomepage
path: root/plugins/weblog
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-06-06 15:13:39 +0200
committerRoland Reichwein <mail@reichwein.it>2020-06-06 15:13:39 +0200
commit357cf76409d30341a2c4eedcf2568f0abd56e88d (patch)
treeaa9a6121fa9e7827b854ec4c744d60c4f1375e50 /plugins/weblog
parentc899a9cb581aa67be94231eba02f432a199512e7 (diff)
More runtime error checking
Diffstat (limited to 'plugins/weblog')
-rw-r--r--plugins/weblog/weblog.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/plugins/weblog/weblog.cpp b/plugins/weblog/weblog.cpp
index 1e1b6b2..a64ee1b 100644
--- a/plugins/weblog/weblog.cpp
+++ b/plugins/weblog/weblog.cpp
@@ -244,6 +244,9 @@ namespace {
size_t page)
{
try {
+ if (page > std::numeric_limits<int>::max())
+ throw std::runtime_error("Bad page index: "s + std::to_string(page));
+
HtmlPage htmlPage{GetRequestParam, "<h1>"s + GetRequestParam("WEBLOG_NAME") + "</h1>"s};
fs::path link{ GetRequestParam("plugin_path")};
@@ -422,7 +425,11 @@ std::string weblog_plugin::generate_page(
size_t page {0};
auto it {query.find("page")};
if (it != query.end()) {
- page = stoul(it->second);
+ try {
+ page = stoul(it->second);
+ } catch(...) {
+ // ignore: keep default 0
+ }
}
if (is_index_page(rel_target))