Skip to content

Commit 994cc2b

Browse files
author
Daniel Neto
committed
fix: Refactor SQL query in fixCleanTitle method to use prepared statements for improved security
https://github.com/WWBN/AVideo/security/advisories/GHSA-584p-rpvq-35vf#event-592857
1 parent 33ea2be commit 994cc2b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

objects/category.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,14 @@ public static function fixCleanTitle($clean_title, $count, $id, $original_title
226226
$original_title = $clean_title;
227227
}
228228

229-
$sql = "SELECT * FROM categories WHERE clean_name = '{$clean_title}' ";
229+
$id = intval($id);
230230
if (!empty($id)) {
231-
$sql .= " AND id != {$id} ";
231+
$sql = "SELECT * FROM categories WHERE clean_name = ? AND id != ? LIMIT 1";
232+
$res = sqlDAL::readSql($sql, "si", [$clean_title, $id], true);
233+
} else {
234+
$sql = "SELECT * FROM categories WHERE clean_name = ? LIMIT 1";
235+
$res = sqlDAL::readSql($sql, "s", [$clean_title], true);
232236
}
233-
$sql .= " LIMIT 1";
234-
$res = sqlDAL::readSql($sql, "", [], true);
235237
$cleanTitleExists = sqlDAL::fetchAssoc($res);
236238
sqlDAL::close($res);
237239
if (!empty($cleanTitleExists)) {

0 commit comments

Comments
 (0)