feat(announcer): Added is_numeric() checking for some fields (#1766)

This commit is contained in:
Roman Kelesidis 2025-01-16 16:09:34 +03:00 committed by GitHub
commit 096bb5124f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View file

@ -126,20 +126,21 @@ if (strlen($info_hash) !== 20) {
*/ */
if ( if (
!isset($port) !isset($port)
|| !is_numeric($port)
|| ($port < 1024 && !$stopped) || ($port < 1024 && !$stopped)
|| $port > 0xFFFF) { || $port > 0xFFFF) {
msg_die('Invalid port: ' . $port); msg_die('Invalid port: ' . $port);
} }
if (!isset($uploaded) || $uploaded < 0) { if (!isset($uploaded) || !is_numeric($uploaded) || $uploaded < 0) {
msg_die('Invalid uploaded value: ' . $uploaded); msg_die('Invalid uploaded value: ' . $uploaded);
} }
if (!isset($downloaded) || $downloaded < 0) { if (!isset($downloaded) || !is_numeric($downloaded) || $downloaded < 0) {
msg_die('Invalid downloaded value: ' . $downloaded); msg_die('Invalid downloaded value: ' . $downloaded);
} }
if (!isset($left) || $left < 0) { if (!isset($left) || !is_numeric($left) || $left < 0) {
msg_die('Invalid left value: ' . $left); msg_die('Invalid left value: ' . $left);
} }
@ -237,7 +238,7 @@ if ($lp_info) {
/** /**
* Currently torrent clients send truncated v2 hashes (the design raises questions). * Currently torrent clients send truncated v2 hashes (the design raises questions).
* https://github.com/bittorrent/bittorrent.org/issues/145#issuecomment-1720040343 * @see https://github.com/bittorrent/bittorrent.org/issues/145#issuecomment-1720040343
*/ */
$info_hash_where = "WHERE tor.info_hash = '$info_hash_sql' OR SUBSTRING(tor.info_hash_v2, 1, 20) = '$info_hash_sql'"; $info_hash_where = "WHERE tor.info_hash = '$info_hash_sql' OR SUBSTRING(tor.info_hash_v2, 1, 20) = '$info_hash_sql'";

View file

@ -68,7 +68,7 @@ if (!empty($info_hash_count)) {
/** /**
* Currently torrent clients send truncated v2 hashes (the design raises questions). * Currently torrent clients send truncated v2 hashes (the design raises questions).
* https://github.com/bittorrent/bittorrent.org/issues/145#issuecomment-1720040343 * @see https://github.com/bittorrent/bittorrent.org/issues/145#issuecomment-1720040343
*/ */
$info_hash_where = "tor.info_hash IN ('$info_hashes_sql') OR SUBSTRING(tor.info_hash_v2, 1, 20) IN ('$info_hashes_sql')"; $info_hash_where = "tor.info_hash IN ('$info_hashes_sql') OR SUBSTRING(tor.info_hash_v2, 1, 20) IN ('$info_hashes_sql')";