Skip to content

Commit 1391d41

Browse files
committed
minor #1386 Limit page size to prevent integer overflow (Tobion)
This PR was merged into the main branch. Discussion ---------- Limit page size to prevent integer overflow The $param is typed int. So if the routing param does not fit into an int, PHP will throw a TypeError. This in turn would trigger an 500 internal server error. So by requesting a too big page, e.g. `/de/blog/page/147483647147483647147483647`, one can trigger internal errors which should not be possible. I don't think there is an easy solution to this general problem that Symfony could automatically provide. So the best solution seems to be to limit the size of the routing placeholder. With this limit the page will always fit into an int even on a 32-bit platform. Commits ------- 8e14d5c Limit page size to prevent int overflow
2 parents a126a9b + 8e14d5c commit 1391d41

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Controller/BlogController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class BlogController extends AbstractController
4646
*/
4747
#[Route('/', defaults: ['page' => '1', '_format' => 'html'], methods: ['GET'], name: 'blog_index')]
4848
#[Route('/rss.xml', defaults: ['page' => '1', '_format' => 'xml'], methods: ['GET'], name: 'blog_rss')]
49-
#[Route('/page/{page<[1-9]\d*>}', defaults: ['_format' => 'html'], methods: ['GET'], name: 'blog_index_paginated')]
49+
#[Route('/page/{page<[1-9]\d{0,8}>}', defaults: ['_format' => 'html'], methods: ['GET'], name: 'blog_index_paginated')]
5050
#[Cache(smaxage: 10)]
5151
public function index(Request $request, int $page, string $_format, PostRepository $posts, TagRepository $tags): Response
5252
{

0 commit comments

Comments
 (0)