Skip to content

Commit 5a28b63

Browse files
committed
Limit maximal numver of fields to 4096
Signed-off-by: Michal Čihař <michal@cihar.com>
1 parent ae8693d commit 5a28b63

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

tbl_addfield.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@
3737
if (isset($_REQUEST['orig_field_where'])) {
3838
$_REQUEST['field_where'] = $_REQUEST['orig_field_where'];
3939
}
40-
$num_fields = $_REQUEST['orig_num_fields'] + $_REQUEST['added_fields'];
40+
$num_fields = min(
41+
intval($_REQUEST['orig_num_fields']) + intval($_REQUEST['added_fields']),
42+
4096
43+
);
4144
$regenerate = true;
4245
} elseif (isset($_REQUEST['num_fields']) && intval($_REQUEST['num_fields']) > 0) {
43-
$num_fields = (int) $_REQUEST['num_fields'];
46+
$num_fields = min(4096, intval($_REQUEST['num_fields']));
4447
} else {
4548
$num_fields = 1;
4649
}

tbl_create.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@
4141
// check number of fields to be created
4242
if (isset($_REQUEST['submit_num_fields'])) {
4343
$regenerate = true; // for libraries/tbl_columns_definition_form.inc.php
44-
$num_fields = $_REQUEST['orig_num_fields'] + $_REQUEST['added_fields'];
44+
$num_fields = min(
45+
intval($_REQUEST['orig_num_fields']) + intval($_REQUEST['added_fields']),
46+
4096
47+
);
4548
} elseif (isset($_REQUEST['num_fields']) && intval($_REQUEST['num_fields']) > 0) {
46-
$num_fields = (int) $_REQUEST['num_fields'];
49+
$num_fields = min(4096, intval($_REQUEST['num_fields']));
4750
} else {
4851
$num_fields = 4;
4952
}

0 commit comments

Comments
 (0)