Skip to content

Commit 62ae47c

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

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

libraries/create_addfield.lib.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,14 @@ function PMA_getTableCreationQuery($db, $table)
335335
function PMA_getNumberOfFieldsFromRequest()
336336
{
337337
if (isset($_REQUEST['submit_num_fields'])) {
338-
$num_fields = $_REQUEST['orig_num_fields'] + $_REQUEST['added_fields'];
338+
$num_fields = min(
339+
4096,
340+
intval($_REQUEST['orig_num_fields']) + intval($_REQUEST['added_fields'])
341+
);
339342
} elseif (isset($_REQUEST['num_fields'])
340343
&& intval($_REQUEST['num_fields']) > 0
341344
) {
342-
$num_fields = (int) $_REQUEST['num_fields'];
345+
$num_fields = min(4096, intval($_REQUEST['num_fields']));
343346
} else {
344347
$num_fields = 4;
345348
}

normalization.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
exit;
2929
}
3030
if (isset($_REQUEST['splitColumn'])) {
31-
$num_fields = $_REQUEST['numFields'];
31+
$num_fields = min(4096, intval($_REQUEST['numFields']));
3232
$html = PMA_getHtmlForCreateNewColumn($num_fields, $db, $table);
3333
$html .= PMA_URL_getHiddenInputs($db, $table);
3434
echo $html;

tbl_addfield.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,13 @@
4242
if (isset($_REQUEST['orig_field_where'])) {
4343
$_REQUEST['field_where'] = $_REQUEST['orig_field_where'];
4444
}
45-
$num_fields = $_REQUEST['orig_num_fields'] + $_REQUEST['added_fields'];
45+
$num_fields = min(
46+
intval($_REQUEST['orig_num_fields']) + intval($_REQUEST['added_fields']),
47+
4096
48+
);
4649
$regenerate = true;
4750
} elseif (isset($_REQUEST['num_fields']) && intval($_REQUEST['num_fields']) > 0) {
48-
$num_fields = (int) $_REQUEST['num_fields'];
51+
$num_fields = min(4096, intval($_REQUEST['num_fields']));
4952
} else {
5053
$num_fields = 1;
5154
}

0 commit comments

Comments
 (0)