Add a few more validity checks

This commit is contained in:
whatever127 2019-09-14 17:26:57 +02:00
parent 39353cdb51
commit d628c2fe69
5 changed files with 21 additions and 2 deletions

View File

@ -164,7 +164,7 @@ function uupFetchUpd(
'updateTitle' => $updateArray[0]['updateTitle'], 'updateTitle' => $updateArray[0]['updateTitle'],
'foundBuild' => $updateArray[0]['foundBuild'], 'foundBuild' => $updateArray[0]['foundBuild'],
'arch' => $updateArray[0]['arch'], 'arch' => $updateArray[0]['arch'],
'fileWrite' => $updateArray[0]['foundBuild'], 'fileWrite' => $updateArray[0]['fileWrite'],
'updateArray' => $updateArray, 'updateArray' => $updateArray,
); );
} }

View File

@ -37,6 +37,14 @@ function uupGetFiles(
) { ) {
uupApiPrintBrand(); uupApiPrintBrand();
if(!$updateId) {
return array('error' => 'UNSPECIFIED_UPDATE');
}
if(!uupApiCheckUpdateId($updateId)) {
return array('error' => 'INCORRECT_ID');
}
$info = @file_get_contents('fileinfo/'.$updateId.'.json'); $info = @file_get_contents('fileinfo/'.$updateId.'.json');
if(empty($info)) { if(empty($info)) {
$info = array( $info = array(

View File

@ -24,6 +24,10 @@ function uupListEditions($lang = 'en-us', $updateId = 0) {
$info = uupUpdateInfo($updateId); $info = uupUpdateInfo($updateId);
} }
if(!$lang) {
return array('error' => 'UNSUPPORTED_LANG');
}
if(isset($info['info'])) $info = $info['info']; if(isset($info['info'])) $info = $info['info'];
if(isset($info['build'])) { if(isset($info['build'])) {

View File

@ -16,7 +16,7 @@ limitations under the License.
*/ */
function uupApiVersion() { function uupApiVersion() {
return '1.26.2'; return '1.27.0';
} }
require_once dirname(__FILE__).'/auths.php'; require_once dirname(__FILE__).'/auths.php';

View File

@ -113,3 +113,10 @@ function uupDumpApiGetDebug() {
$data = parse_ini_file('debug.ini'); $data = parse_ini_file('debug.ini');
return $data; return $data;
} }
function uupApiCheckUpdateId($updateId) {
return preg_match(
'/^[\da-fA-F]{8}-([\da-fA-F]{4}-){3}[\da-fA-F]{12}(_rev\.\d+)?$/',
$updateId
);
}