mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-04 18:42:15 +02:00
Version checking, ensure output pointers are non-null
This commit is contained in:
parent
609ef24037
commit
3adb7f9918
@ -188,7 +188,11 @@ Result fsOpenDataStorageByCurrentProcess(FsStorage* out);
|
||||
Result fsOpenDataStorageByDataId(FsStorage* out, u64 dataId, FsStorageId storageId);
|
||||
Result fsOpenDeviceOperator(FsDeviceOperator* 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);
|
||||
|
||||
// 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);
|
||||
// todo: Rest of commands here
|
||||
|
||||
|
@ -504,6 +504,9 @@ Result fsOpenSdCardDetectionEventNotifier(FsEventNotifier* out) {
|
||||
}
|
||||
|
||||
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};
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
@ -535,7 +538,7 @@ Result fsGetRightsIdByPath(const char* path, FsRightsId* out_rights_id) {
|
||||
rc = resp->result;
|
||||
|
||||
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) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
char send_path[FS_MAX_PATH] = {0};
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
@ -576,8 +582,8 @@ Result fsGetRightsIdAndKeyGenerationByPath(const char* path, u8* out_key_generat
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
*out_key_generation = resp->key_generation;
|
||||
*out_rights_id = resp->rights_id;
|
||||
if (out_key_generation) *out_key_generation = resp->key_generation;
|
||||
if (out_rights_id) *out_rights_id = resp->rights_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user