diff --git a/amxmodx/amxxfile.cpp b/amxmodx/amxxfile.cpp index 9ddb9921..0d3622f1 100755 --- a/amxmodx/amxxfile.cpp +++ b/amxmodx/amxxfile.cpp @@ -289,7 +289,18 @@ size_t CAmxxReader::GetBufferSize() m_pFile = NULL; \ return m_Status; \ } - +#define DATAREAD_RELEASE(addr, itemsize, itemcount) \ + if (fread(addr, itemsize, itemcount, m_pFile) != static_cast(itemcount)) \ + { \ + if (feof(m_pFile)) \ + m_Status = Err_FileInvalid; \ + else \ + m_Status = Err_FileRead; \ + fclose(m_pFile); \ + m_pFile = NULL; \ + delete[] tempBuffer;\ + return m_Status; \ + } CAmxxReader::Error CAmxxReader::GetSection(void *buffer) { if (!m_pFile) @@ -311,7 +322,7 @@ CAmxxReader::Error CAmxxReader::GetSection(void *buffer) PluginEntry *pe = &(m_Bh.plugins[m_Entry]); char *tempBuffer = new char[m_SectionLength + 1]; fseek(m_pFile, pe->offs, SEEK_SET); - DATAREAD((void *)tempBuffer, 1, m_SectionLength); + DATAREAD_RELEASE((void *)tempBuffer, 1, m_SectionLength); uLongf destLen = GetBufferSize(); int result = uncompress((Bytef *)buffer, &destLen, (Bytef *)tempBuffer, m_SectionLength); delete [] tempBuffer; @@ -335,7 +346,7 @@ CAmxxReader::Error CAmxxReader::GetSection(void *buffer) // read the data to a temporary buffer char *tempBuffer = new char[m_SectionLength + 1]; //fread(tempBuffer, sizeof(char), m_SectionLength, m_pFile); - DATAREAD((void*)tempBuffer, 1, m_SectionLength); + DATAREAD_RELEASE((void*)tempBuffer, 1, m_SectionLength); // decompress int result = uncompress((Bytef *)buffer, &destLen, (Bytef *)tempBuffer, m_SectionLength); delete [] tempBuffer; diff --git a/amxmodx/file.cpp b/amxmodx/file.cpp index 3b51f88d..7d66761b 100755 --- a/amxmodx/file.cpp +++ b/amxmodx/file.cpp @@ -96,12 +96,14 @@ static cell AMX_NATIVE_CALL read_file(AMX *amx, cell *params) { length = strlen(buffer); - if (buffer[length - 1] == '\n') + if (length > 0) + { + if (buffer[length - 1] == '\n') buffer[--length] = '\0'; - if (buffer[length - 1] == '\r') + if (buffer[length - 1] == '\r') buffer[--length] = '\0'; - + } cell* textLen = get_amxaddr(amx, params[5]); *textLen = set_amxstring_utf8(amx, params[3], buffer, length, params[4]); diff --git a/compiler/libpc300/sci18n.c b/compiler/libpc300/sci18n.c index 40912c46..92439b5e 100755 --- a/compiler/libpc300/sci18n.c +++ b/compiler/libpc300/sci18n.c @@ -46,7 +46,7 @@ #define _MAX_PATH 250 #endif #if !defined DIRSEP_CHAR - #if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE___ + #if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ #define DIRSEP_CHAR '/' #elif defined macintosh #define DIRSEP_CHAR ':' diff --git a/modules/cstrike/csx/WinCSX/WinCSX.cpp b/modules/cstrike/csx/WinCSX/WinCSX.cpp index 6ff54ff2..36ac4d95 100644 --- a/modules/cstrike/csx/WinCSX/WinCSX.cpp +++ b/modules/cstrike/csx/WinCSX/WinCSX.cpp @@ -229,8 +229,8 @@ void ListboxItemSelected(HWND hDlg) { // Retrieve complete stats record of this position. Position in listbox should be same as rank in our records! RankSystem::RankStats* stats = g_rank.findEntryInRankByPos((int)nItem + 1); if (stats == NULL) { - char msg[] = "Error: Couldn't find the record by position! (nItem = %d)"; - sprintf(msg, msg, nItem); + char msg[512]; + sprintf(msg, "Error: Couldn't find the record by position! (nItem = %d)", nItem); MessageBox(hDlg, msg, "Oh fiddlesticks!", MB_OK); ClearStatsfields(hDlg); return; diff --git a/modules/cstrike/csx/rank.cpp b/modules/cstrike/csx/rank.cpp index 7a94d419..e7213182 100644 --- a/modules/cstrike/csx/rank.cpp +++ b/modules/cstrike/csx/rank.cpp @@ -307,10 +307,10 @@ static cell AMX_NATIVE_CALL custom_wpn_dmg(AMX *amx, cell *params){ // wid,att,v CPlayer* pAtt = GET_PLAYER_POINTER_I(att); CPlayer* pVic = GET_PLAYER_POINTER_I(vic); + if ( !pAtt ) pAtt = pVic; pVic->pEdict->v.dmg_inflictor = NULL; pAtt->saveHit( pVic , weapon , dmg, aim ); - if ( !pAtt ) pAtt = pVic; int TA = 0; if ( (pVic->teamId == pAtt->teamId) && ( pVic != pAtt) ) TA = 1; diff --git a/modules/dod/dodfun/NPD.cpp b/modules/dod/dodfun/NPD.cpp index 98cf2fd3..3343e51c 100644 --- a/modules/dod/dodfun/NPD.cpp +++ b/modules/dod/dodfun/NPD.cpp @@ -506,7 +506,7 @@ static cell AMX_NATIVE_CALL objective_set_data(AMX *amx, cell *params){ // index GET_CP_PD(pent).model_body_neutral = ivalue; return 1; case CP_model_body_allies : - GET_CP_PD(pent).model_body_axis = ivalue; + GET_CP_PD(pent).model_body_allies = ivalue; return 1; case CP_model_body_axis : GET_CP_PD(pent).model_body_axis = ivalue; diff --git a/modules/dod/dodx/NBase.cpp b/modules/dod/dodx/NBase.cpp index 3e9adfd5..c06c9f89 100644 --- a/modules/dod/dodx/NBase.cpp +++ b/modules/dod/dodx/NBase.cpp @@ -387,12 +387,12 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params) pVic->pEdict->v.dmg_inflictor = NULL; - if(pAtt->index != pVic->index) - pAtt->saveHit(pVic , weapon , dmg, aim); - if(!pAtt) pAtt = pVic; + if(pAtt->index != pVic->index) + pAtt->saveHit(pVic , weapon , dmg, aim); + int TA = 0; if((pVic->pEdict->v.team == pAtt->pEdict->v.team) && (pVic != pAtt)) diff --git a/modules/fakemeta/fm_tr2.cpp b/modules/fakemeta/fm_tr2.cpp index 83edbc7a..70691cea 100644 --- a/modules/fakemeta/fm_tr2.cpp +++ b/modules/fakemeta/fm_tr2.cpp @@ -1110,9 +1110,9 @@ static cell AMX_NATIVE_CALL set_es(AMX *amx, cell *params) es->vuser3.z = amx_ctof(ptr[2]); return 1; case ES_vUser4: - es->vuser3.x = amx_ctof(ptr[0]); - es->vuser3.y = amx_ctof(ptr[1]); - es->vuser3.z = amx_ctof(ptr[2]); + es->vuser4.x = amx_ctof(ptr[0]); + es->vuser4.y = amx_ctof(ptr[1]); + es->vuser4.z = amx_ctof(ptr[2]); return 1; } diff --git a/modules/tfcx/NRank.cpp b/modules/tfcx/NRank.cpp index a81f3af4..10e6a2e7 100644 --- a/modules/tfcx/NRank.cpp +++ b/modules/tfcx/NRank.cpp @@ -262,10 +262,10 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg CPlayer* pAtt = GET_PLAYER_POINTER_I(att); CPlayer* pVic = GET_PLAYER_POINTER_I(vic); + if ( !pAtt ) pAtt = pVic; pVic->pEdict->v.dmg_inflictor = NULL; pAtt->saveHit( pVic , weapon , dmg, aim ); - if ( !pAtt ) pAtt = pVic; int TA = 0; if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) ) TA = 1; diff --git a/modules/tfcx/Utils.cpp b/modules/tfcx/Utils.cpp index 10374b8b..8033e1d7 100644 --- a/modules/tfcx/Utils.cpp +++ b/modules/tfcx/Utils.cpp @@ -47,7 +47,7 @@ bool isModuleActive(){ bool util_strncmp( const char *sz1, const char *sz2, int size){ int i = 0; - while( sz1[i] && i<=size){ + while( i<=size && sz1[i] ){ if ( sz1[i] != sz2[i] ) return false; i++; diff --git a/modules/ts/tsx/NRank.cpp b/modules/ts/tsx/NRank.cpp index 64ba7611..049c4d17 100644 --- a/modules/ts/tsx/NRank.cpp +++ b/modules/ts/tsx/NRank.cpp @@ -295,10 +295,10 @@ static cell AMX_NATIVE_CALL cwpn_dmg(AMX *amx, cell *params){ // wid,att,vic,dmg CPlayer* pAtt = GET_PLAYER_POINTER_I(att); CPlayer* pVic = GET_PLAYER_POINTER_I(vic); + if ( !pAtt ) pAtt = pVic; pVic->pEdict->v.dmg_inflictor = NULL; pAtt->saveHit( pVic , weapon , dmg, aim ); - - if ( !pAtt ) pAtt = pVic; + int TA = 0; if ( (pVic->pEdict->v.team == pAtt->pEdict->v.team ) && ( pVic != pAtt) ) TA = 1; diff --git a/modules/ts/tsx/usermsg.cpp b/modules/ts/tsx/usermsg.cpp index e194d739..1cbcac03 100644 --- a/modules/ts/tsx/usermsg.cpp +++ b/modules/ts/tsx/usermsg.cpp @@ -122,7 +122,8 @@ void Client_TSHealth_End(void* mValue){ weapon = 37; // throwing knife aim = pAttacker ? pAttacker->aiming : 0; - pAttacker->saveHit( mPlayer , weapon , damage, aim ); + if (pAttacker) + pAttacker->saveHit( mPlayer , weapon , damage, aim ); } } if ( !pAttacker ) pAttacker = mPlayer; diff --git a/third_party/libmaxminddb/maxminddb.c b/third_party/libmaxminddb/maxminddb.c index 7580e1ea..9d89f244 100644 --- a/third_party/libmaxminddb/maxminddb.c +++ b/third_party/libmaxminddb/maxminddb.c @@ -831,7 +831,7 @@ MMDB_lookup_result_s MMDB_lookup_string(MMDB_s *const mmdb, struct addrinfo *addresses = NULL; *gai_error = resolve_any_address(ipstr, &addresses); - if (!*gai_error) { + if (!*gai_error && NULL != addresses) { result = MMDB_lookup_sockaddr(mmdb, addresses->ai_addr, mmdb_error); }