aboutsummaryrefslogtreecommitdiffstats
path: root/form.c
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2016-08-17 10:47:19 +0000
committerTatsuya Kinoshita <tats@debian.org>2016-08-17 10:47:19 +0000
commita25fd09f74fb83499396935a96d63bb7cb8e2c58 (patch)
treebd6253483c701f480377482c722f074c28bc3ac9 /form.c
parentUpdate ChangeLog (diff)
downloadw3m-a25fd09f74fb83499396935a96d63bb7cb8e2c58.tar.gz
w3m-a25fd09f74fb83499396935a96d63bb7cb8e2c58.zip
Prevent negative array index for selectnumber and textareanumber
Bug-Debian: https://github.com/tats/w3m/issues/12
Diffstat (limited to 'form.c')
-rw-r--r--form.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/form.c b/form.c
index 87a5d49..da115fa 100644
--- a/form.c
+++ b/form.c
@@ -10,8 +10,10 @@
#include "regex.h"
extern Str *textarea_str;
+extern int max_textarea;
#ifdef MENU_SELECT
extern FormSelectOption *select_option;
+extern int max_select;
#include "menu.h"
#endif /* MENU_SELECT */
@@ -122,10 +124,12 @@ formList_addInput(struct form_list *fl, struct parsed_tag *tag)
parsedtag_get_value(tag, ATTR_SIZE, &item->size);
parsedtag_get_value(tag, ATTR_MAXLENGTH, &item->maxlength);
item->readonly = parsedtag_exists(tag, ATTR_READONLY);
- if (parsedtag_get_value(tag, ATTR_TEXTAREANUMBER, &i))
+ if (parsedtag_get_value(tag, ATTR_TEXTAREANUMBER, &i)
+ && i >= 0 && i < max_textarea)
item->value = item->init_value = textarea_str[i];
#ifdef MENU_SELECT
- if (parsedtag_get_value(tag, ATTR_SELECTNUMBER, &i))
+ if (parsedtag_get_value(tag, ATTR_SELECTNUMBER, &i)
+ && i >= 0 && i < max_select)
item->select_option = select_option[i].first;
#endif /* MENU_SELECT */
if (parsedtag_get_value(tag, ATTR_ROWS, &p))