Version checking, ensure output pointers are non-null

This commit is contained in:
Adubbz 2019-06-03 10:48:28 +10:00
parent 609ef24037
commit 3adb7f9918
2 changed files with 13 additions and 3 deletions

View File

@ -188,7 +188,11 @@ Result fsOpenDataStorageByCurrentProcess(FsStorage* out);
Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, FsStorageId storageId); Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, FsStorageId storageId);
Result fsOpenDeviceOperator(FsDeviceOperator* out); Result fsOpenDeviceOperator(FsDeviceOperator* out);
Result fsOpenSdCardDetectionEventNotifier(FsEventNotifier* out); Result fsOpenSdCardDetectionEventNotifier(FsEventNotifier* out);
// Retrieves the rights id corresponding to the content path. Only available on [2.0.0+].
Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id); Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id);
// Retrieves the rights id and key generation corresponding to the content path. Only available on [3.0.0+].
Result fsGetRightsIdAndKeyGenerationByPath(const char* path, u8* out_key_generation, FsRightsId* out_rights_id); Result fsGetRightsIdAndKeyGenerationByPath(const char* path, u8* out_key_generation, FsRightsId* out_rights_id);
// todo: Rest of commands here // todo: Rest of commands here

View File

@ -504,6 +504,9 @@ Result fsOpenSdCardDetectionEventNotifier(FsEventNotifier* out) {
} }
Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id) { Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id) {
if (hosversionBefore(2,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
char send_path[FS_MAX_PATH] = {0}; char send_path[FS_MAX_PATH] = {0};
IpcCommand c; IpcCommand c;
ipcInitialize(&c); ipcInitialize(&c);
@ -535,7 +538,7 @@ Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id) {
rc = resp->result; rc = resp->result;
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
*out_rights_id = resp->rights_id; if (out_rights_id) *out_rights_id = resp->rights_id;
} }
} }
@ -543,6 +546,9 @@ Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id) {
} }
Result fsGetRightsIdAndKeyGenerationByPath(const char* path, u8* out_key_generation, FsRightsId* out_rights_id) { Result fsGetRightsIdAndKeyGenerationByPath(const char* path, u8* out_key_generation, FsRightsId* out_rights_id) {
if (hosversionBefore(3,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
char send_path[FS_MAX_PATH] = {0}; char send_path[FS_MAX_PATH] = {0};
IpcCommand c; IpcCommand c;
ipcInitialize(&c); ipcInitialize(&c);
@ -576,8 +582,8 @@ Result fsGetRightsIdAndKeyGenerationByPath(const char* path, u8* out_key_generat
rc = resp->result; rc = resp->result;
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
*out_key_generation = resp->key_generation; if (out_key_generation) *out_key_generation = resp->key_generation;
*out_rights_id = resp->rights_id; if (out_rights_id) *out_rights_id = resp->rights_id;
} }
} }