mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Log level tweaks, fix dodgy string tricks that failed the memory sanitizer
This commit is contained in:
parent
1dc93ef8db
commit
1c16c31b49
4 changed files with 16 additions and 18 deletions
|
@ -2356,23 +2356,23 @@ bool resolveMAC(SceNetEtherAddr* mac, uint32_t* ip, u16* port_offset) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool validNetworkName(const SceNetAdhocctlGroupName * group_name) {
|
||||
bool validNetworkName(const char *data) {
|
||||
// Result
|
||||
bool valid = true;
|
||||
|
||||
// Name given
|
||||
if (group_name != NULL) {
|
||||
if (data != NULL) {
|
||||
// Iterate Name Characters
|
||||
for (int i = 0; i < ADHOCCTL_GROUPNAME_LEN && valid; i++) {
|
||||
// End of Name
|
||||
if (group_name->data[i] == 0) break;
|
||||
if (data[i] == 0) break;
|
||||
|
||||
// Not a digit
|
||||
if (group_name->data[i] < '0' || group_name->data[i] > '9') {
|
||||
if (data[i] < '0' || data[i] > '9') {
|
||||
// Not 'A' to 'Z'
|
||||
if (group_name->data[i] < 'A' || group_name->data[i] > 'Z') {
|
||||
if (data[i] < 'A' || data[i] > 'Z') {
|
||||
// Not 'a' to 'z'
|
||||
if (group_name->data[i] < 'a' || group_name->data[i] > 'z') {
|
||||
if (data[i] < 'a' || data[i] > 'z') {
|
||||
// Invalid Name
|
||||
valid = false;
|
||||
}
|
||||
|
|
|
@ -1469,7 +1469,7 @@ bool resolveMAC(SceNetEtherAddr* mac, uint32_t* ip, u16* port_offset = nullptr);
|
|||
* @param group_name To-be-checked Network Name
|
||||
* @return 1 if valid or... 0
|
||||
*/
|
||||
bool validNetworkName(const SceNetAdhocctlGroupName * groupname);
|
||||
bool validNetworkName(const char *data);
|
||||
|
||||
// Convert Matching Event Code to String
|
||||
const char* getMatchingEventStr(int code);
|
||||
|
|
|
@ -2751,12 +2751,11 @@ int sceNetAdhocctlGetPeerInfo(const char *mac, int size, u32 peerInfoAddr) {
|
|||
return ERROR_NET_ADHOCCTL_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
int NetAdhocctl_Create(const char* groupName) {
|
||||
const SceNetAdhocctlGroupName* groupNameStruct = (const SceNetAdhocctlGroupName*)groupName;
|
||||
int NetAdhocctl_Create(const char *groupName) {
|
||||
// Library initialized
|
||||
if (netAdhocctlInited) {
|
||||
// Valid Argument
|
||||
if (validNetworkName(groupNameStruct)) {
|
||||
if (validNetworkName(groupName)) {
|
||||
// FIXME: When tested with JPCSP + official prx files it seems when adhocctl in a connected state (ie. joined to a group) attempting to create/connect/join/scan will return a success (without doing anything?)
|
||||
if ((adhocctlState == ADHOCCTL_STATE_CONNECTED) || (adhocctlState == ADHOCCTL_STATE_GAMEMODE)) {
|
||||
// TODO: Need to test this on games that doesn't use Adhocctl Handler too (not sure if there are games like that tho)
|
||||
|
@ -2771,12 +2770,11 @@ int NetAdhocctl_Create(const char* groupName) {
|
|||
isAdhocctlNeedLogin = true;
|
||||
|
||||
// Set Network Name
|
||||
if (groupNameStruct != NULL)
|
||||
parameter.group_name = *groupNameStruct;
|
||||
|
||||
// Reset Network Name
|
||||
else
|
||||
if (groupName) {
|
||||
truncate_cpy((char *)parameter.group_name.data, sizeof(parameter.group_name.data), groupName);
|
||||
} else {
|
||||
memset(¶meter.group_name, 0, sizeof(parameter.group_name));
|
||||
}
|
||||
|
||||
// Set HUD Connection Status
|
||||
//setConnectionStatus(1);
|
||||
|
@ -2841,7 +2839,7 @@ int sceNetAdhocctlCreate(const char *groupName) {
|
|||
int sceNetAdhocctlConnect(const char* groupName) {
|
||||
char grpName[ADHOCCTL_GROUPNAME_LEN + 1] = { 0 };
|
||||
if (groupName)
|
||||
memcpy(grpName, groupName, ADHOCCTL_GROUPNAME_LEN); // For logging purpose, must not be truncated
|
||||
strncpy(grpName, groupName, ADHOCCTL_GROUPNAME_LEN); // For logging purpose, must not be truncated
|
||||
INFO_LOG(Log::sceNet, "sceNetAdhocctlConnect(%s) at %08x", grpName, currentMIPS->pc);
|
||||
if (!g_Config.bEnableWlan) {
|
||||
return -1;
|
||||
|
|
|
@ -592,7 +592,7 @@ int sceNetInetPoll(void *fds, u32 nfds, int timeout) { // timeout in miliseconds
|
|||
}
|
||||
|
||||
static int sceNetInetSelect(int maxfd, u32 readFdsPtr, u32 writeFdsPtr, u32 exceptFdsPtr, u32 timeoutPtr) {
|
||||
WARN_LOG_ONCE(sceNetInetSelect, Log::sceNet, "UNTESTED sceNetInetSelect(%i, %08x, %08x, %08x, %08x)", maxfd, readFdsPtr, writeFdsPtr, exceptFdsPtr, timeoutPtr);
|
||||
DEBUG_LOG(Log::sceNet, "sceNetInetSelect(%i, %08x, %08x, %08x, %08x)", maxfd, readFdsPtr, writeFdsPtr, exceptFdsPtr, timeoutPtr);
|
||||
const auto sceNetInet = SceNetInet::Get();
|
||||
if (!sceNetInet) {
|
||||
return hleLogError(Log::sceNet, ERROR_NET_INET_CONFIG_INVALID_ARG, "Inet Subsystem Not Running - Use sceNetInetInit");
|
||||
|
@ -627,7 +627,7 @@ static int sceNetInetSelect(int maxfd, u32 readFdsPtr, u32 writeFdsPtr, u32 exce
|
|||
ERROR_LOG(Log::sceNet, "%s: Received error from select() %i: %s", __func__, error, strerror(error));
|
||||
}
|
||||
|
||||
INFO_LOG(Log::sceNet, "%s: select() returned %i", __func__, ret);
|
||||
DEBUG_LOG(Log::sceNet, "%s: select() returned %i", __func__, ret);
|
||||
return hleDelayResult(ret, "TODO: unhack", 500);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue