From 439795e63b1468000992275320b6c7e3f43fa9c0 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Wed, 31 Jul 2013 06:40:57 -0400 Subject: [PATCH] Disallow board names which are too large for the filesytem to handle --- inc/mod/pages.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index ab4cdaaf..08604039 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -446,6 +446,23 @@ function mod_new_board() { if (!preg_match('/^' . $config['board_regex'] . '$/u', $_POST['uri'])) error(sprintf($config['error']['invalidfield'], 'URI')); + $bytes = 0; + $chars = preg_split('//u', $_POST['uri'], -1, PREG_SPLIT_NO_EMPTY); + foreach ($chars as $char) { + $o = 0; + $ord = ordutf8($char, $o); + if ($ord > 0x0080) + $bytes += 5; // @01ff + else + $bytes ++; + } + $bytes + strlen('posts_.frm'); + + if ($bytes > 255) { + error('Your filesystem cannot handle a board URI of that length (' . $bytes . '/255 bytes)'); + exit; + } + if (openBoard($_POST['uri'])) { error(sprintf($config['error']['boardexists'], $board['url'])); }