aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--extension/curlmanager.cpp27
-rw-r--r--extension/define.h23
-rw-r--r--extension/natives.cpp15
-rw-r--r--extension/opensslmanager.cpp104
-rw-r--r--extension/sdk/smsdk_config.h2
-rw-r--r--extension/sdk/smsdk_ext.cpp1
6 files changed, 42 insertions, 130 deletions
diff --git a/extension/curlmanager.cpp b/extension/curlmanager.cpp
index 3cf127b..666f74e 100644
--- a/extension/curlmanager.cpp
+++ b/extension/curlmanager.cpp
@@ -1,3 +1,5 @@
+#define CURL_NO_OLDIES
+
#include "curlmanager.h"
#ifdef PLATFORM_LINUX
@@ -23,13 +25,13 @@ struct data_t {
/* Write Function */
static size_t curl_write_function_default(void *ptr, size_t bytes, size_t nmemb, void *stream)
{
- FILE *file = (FILE *)stream;
+ FILE* file = (FILE*)stream;
+ // Pretty sure this is for determining if `stream` is actually a FILE* or not.
+ // This is really terrible and we should not be doing this since it erases types.
#ifdef WIN32
- //if(file->_file >= 3)
-
- if ( _filelength(_fileno(file)) >= 3 )
+ if ( _fileno(file) >= 3 )
#else
- if(file->_fileno >= 3)
+ if( fileno(file) >= 3 )
#endif
{
return fwrite(ptr, bytes, nmemb, file);
@@ -388,9 +390,9 @@ bool cURLManager::AddcURLOptionString(cURLHandle *handle, CURLoption opt, char *
case CURLOPT_FTPPORT:
case CURLOPT_USERAGENT:
case CURLOPT_COOKIE:
- case CURLOPT_ENCODING:
+ //case CURLOPT_ENCODING:
case CURLOPT_CUSTOMREQUEST:
- case CURLOPT_WRITEINFO:
+ //case CURLOPT_WRITEINFO:
case CURLOPT_INTERFACE:
case CURLOPT_KRBLEVEL:
case CURLOPT_SSL_CIPHER_LIST:
@@ -493,7 +495,7 @@ bool cURLManager::AddcURLOptionInt(cURLHandle *handle, CURLoption opt, int value
case CURLOPT_MAXREDIRS:
case CURLOPT_FILETIME:
case CURLOPT_MAXCONNECTS:
- case CURLOPT_CLOSEPOLICY:
+ //case CURLOPT_CLOSEPOLICY:
case CURLOPT_FRESH_CONNECT:
case CURLOPT_FORBID_REUSE:
case CURLOPT_CONNECTTIMEOUT:
@@ -511,7 +513,7 @@ bool cURLManager::AddcURLOptionInt(cURLHandle *handle, CURLoption opt, int value
case CURLOPT_HTTPAUTH:
case CURLOPT_FTP_CREATE_MISSING_DIRS:
case CURLOPT_PROXYAUTH:
- case CURLOPT_FTP_RESPONSE_TIMEOUT:
+ //case CURLOPT_FTP_RESPONSE_TIMEOUT:
case CURLOPT_IPRESOLVE:
case CURLOPT_MAXFILESIZE:
case CURLOPT_USE_SSL:
@@ -736,9 +738,12 @@ void cURLManager::LoadcURLOption(cURLHandle *handle)
curl_easy_setopt(handle->curl, CURLOPT_OPENSOCKETFUNCTION, curl_opensocket_function);
curl_easy_setopt(handle->curl, CURLOPT_OPENSOCKETDATA, handle);
- if(handle->callback_Function[cURL_CallBack_WRITE_FUNCTION] == NULL) {
+ if(handle->callback_Function[cURL_CallBack_WRITE_FUNCTION] == NULL)
+ {
curl_easy_setopt(handle->curl, CURLOPT_WRITEFUNCTION, curl_write_function_default);
- } else {
+ }
+ else
+ {
curl_easy_setopt(handle->curl, CURLOPT_WRITEFUNCTION, curl_write_function_SM);
curl_easy_setopt(handle->curl, CURLOPT_WRITEDATA, handle);
}
diff --git a/extension/define.h b/extension/define.h
index f56ccda..d87104d 100644
--- a/extension/define.h
+++ b/extension/define.h
@@ -149,17 +149,18 @@ enum OpensslThread_Type {
OpensslThread_Type_LAST,
};
-enum Openssl_Hash {
- Openssl_Hash_MD5 = 0,
- Openssl_Hash_MD4,
- Openssl_Hash_MD2,
- Openssl_Hash_SHA,
- Openssl_Hash_SHA1,
- Openssl_Hash_SHA224,
- Openssl_Hash_SHA256,
- Openssl_Hash_SHA384,
- Openssl_Hash_SHA512,
- Openssl_Hash_RIPEMD160,
+enum Openssl_Hash
+{
+ Openssl_Hash_MD5 = 0,
+ Openssl_Hash_DEPRECATED_MD4_UNUSABLE,
+ Openssl_Hash_DEPRECATED_MD2_UNUSABLE,
+ Openssl_Hash_DEPRECATED_SHA_UNUSABLE,
+ Openssl_Hash_SHA1,
+ Openssl_Hash_SHA224,
+ Openssl_Hash_SHA256,
+ Openssl_Hash_SHA384,
+ Openssl_Hash_SHA512,
+ Openssl_Hash_DEPRECATED_RIPEMD160_UNUSABLE,
};
struct Openssl_Hash_pack {
diff --git a/extension/natives.cpp b/extension/natives.cpp
index ef9c2fc..5715677 100644
--- a/extension/natives.cpp
+++ b/extension/natives.cpp
@@ -501,12 +501,13 @@ static cell_t sm_curl_hash_file(IPluginContext *pContext, const cell_t *params)
char *filepath;
pContext->LocalToString(params[1], &filepath);
- int len = strlen(filepath);
+ size_t len = strlen(filepath);
Openssl_Hash_pack *hash_pack = new Openssl_Hash_pack();
hash_pack->UserData = params[4];
- hash_pack->path = new char[len+1];
- strncpy(hash_pack->path, filepath, len);
+ hash_pack->path = new char[len+1]{};
+ snprintf(hash_pack->path, len, "%s", filepath);
+ // strncpy(hash_pack->path, filepath, len);
hash_pack->path[len] = '\0';
hash_pack->hash_callback = pFunction;
@@ -523,9 +524,11 @@ static cell_t sm_curl_hash_string(IPluginContext *pContext, const cell_t *params
Openssl_Hash hashType = (Openssl_Hash)params[3];
if
(
- hashType == Openssl_Hash_MD2
- || hashType == Openssl_Hash_SHA
- )
+ hashType == Openssl_Hash_DEPRECATED_MD2_UNUSABLE
+ || hashType == Openssl_Hash_DEPRECATED_MD4_UNUSABLE
+ || hashType == Openssl_Hash_DEPRECATED_SHA_UNUSABLE
+ || hashType == Openssl_Hash_DEPRECATED_RIPEMD160_UNUSABLE
+ )
{
return pContext->ThrowNativeError("Deprecated hash function %x - Sorry!", params[3]);
}
diff --git a/extension/opensslmanager.cpp b/extension/opensslmanager.cpp
index 26b783b..d97ea2c 100644
--- a/extension/opensslmanager.cpp
+++ b/extension/opensslmanager.cpp
@@ -11,7 +11,7 @@
// -sappho
#define MD5_FILE_BUFFER_SIZE 1024*16
-#define MD4_FILE_BUFFER_SIZE 1024*16
+// #define MD4_FILE_BUFFER_SIZE 1024*16
// #define MD2_FILE_BUFFER_SIZE 1024*16
// #define SHA_FILE_BUFFER_SIZE 1024*16
#define SHA1_FILE_BUFFER_SIZE 1024*16
@@ -19,9 +19,9 @@
#define SHA256_FILE_BUFFER_SIZE 1024*16
#define SHA384_FILE_BUFFER_SIZE 1024*16
#define SHA512_FILE_BUFFER_SIZE 1024*16
-#define RIPEMD160_FILE_BUFFER_SIZE 1024*16
-
+// #define RIPEMD160_FILE_BUFFER_SIZE 1024*16
+#include <openssl/evp.h>
OpensslManager g_OpensslManager;
static IMutex **ssl_lockarray;
@@ -46,68 +46,6 @@ static void MD5_File(FILE *file, unsigned char **output, int *outlength)
MD5_Final(*output, &c);
}
-static void MD4_File(FILE *file, unsigned char **output, int *outlength)
-{
- *output = new unsigned char[MD4_DIGEST_LENGTH];
- *outlength = MD4_DIGEST_LENGTH;
-
- MD4_CTX c;
- int i;
- unsigned char buf[MD4_FILE_BUFFER_SIZE];
-
- MD4_Init(&c);
- for (;;)
- {
- i = fread(buf,1,MD4_FILE_BUFFER_SIZE,file);
- if(i <= 0)
- break;
- MD4_Update(&c,buf,(unsigned long)i);
- }
- MD4_Final(*output, &c);
-}
-
-/*
-static void MD2_File(FILE *file, unsigned char **output, int *outlength)
-{
- *output = new unsigned char[MD2_DIGEST_LENGTH];
- *outlength = MD2_DIGEST_LENGTH;
-
- MD2_CTX c;
- int i;
- unsigned char buf[MD2_FILE_BUFFER_SIZE];
-
- MD2_Init(&c);
- for (;;)
- {
- i = fread(buf,1,MD2_FILE_BUFFER_SIZE,file);
- if(i <= 0)
- break;
- MD2_Update(&c,buf,(unsigned long)i);
- }
- MD2_Final(*output, &c);
-}
-
-static void SHA_File(FILE *file, unsigned char **output, int *outlength)
-{
- *output = new unsigned char[SHA_DIGEST_LENGTH];
- *outlength = SHA_DIGEST_LENGTH;
-
- SHA_CTX c;
- int i;
- unsigned char buf[SHA_FILE_BUFFER_SIZE];
-
- SHA_Init(&c);
- for (;;)
- {
- i = fread(buf,1,SHA_FILE_BUFFER_SIZE,file);
- if(i <= 0)
- break;
- SHA_Update(&c,buf,(unsigned long)i);
- }
- SHA_Final(*output, &c);
-}
-*/
-
static void SHA1_File(FILE *file, unsigned char **output, int *outlength)
{
*output = new unsigned char[SHA_DIGEST_LENGTH];
@@ -195,7 +133,7 @@ static void SHA512_File(FILE *file, unsigned char **output, int *outlength)
SHA512_CTX c;
int i;
- unsigned char buf[SHA384_FILE_BUFFER_SIZE];
+ unsigned char buf[SHA512_FILE_BUFFER_SIZE];
SHA512_Init(&c);
for (;;)
@@ -208,26 +146,6 @@ static void SHA512_File(FILE *file, unsigned char **output, int *outlength)
SHA512_Final(*output, &c);
}
-static void RIPEMD160_File(FILE *file, unsigned char **output, int *outlength)
-{
- *output = new unsigned char[RIPEMD160_DIGEST_LENGTH];
- *outlength = RIPEMD160_DIGEST_LENGTH;
-
- RIPEMD160_CTX c;
- int i;
- unsigned char buf[RIPEMD160_FILE_BUFFER_SIZE];
-
- RIPEMD160_Init(&c);
- for (;;)
- {
- i = fread(buf,1,RIPEMD160_FILE_BUFFER_SIZE,file);
- if(i <= 0)
- break;
- RIPEMD160_Update(&c,buf,(unsigned long)i);
- }
- RIPEMD160_Final(*output, &c);
-}
-
static void ssl_locking_callback(int mode, int type, const char *file, int line)
{
if(mode & CRYPTO_LOCK)
@@ -283,17 +201,6 @@ bool OpensslManager::HashFile(Openssl_Hash algorithm, FILE *pFile, unsigned char
case Openssl_Hash_MD5:
MD5_File(pFile, output, outlength);
return true;
- case Openssl_Hash_MD4:
- MD4_File(pFile, output, outlength);
- return true;
- case Openssl_Hash_MD2:
- //MD2_File(pFile, output, outlength);
- //return true;
- return false;
- case Openssl_Hash_SHA:
- //SHA_File(pFile, output, outlength);
- //return true;
- return false;
case Openssl_Hash_SHA1:
SHA1_File(pFile, output, outlength);
return true;
@@ -309,9 +216,6 @@ bool OpensslManager::HashFile(Openssl_Hash algorithm, FILE *pFile, unsigned char
case Openssl_Hash_SHA512:
SHA512_File(pFile, output, outlength);
return true;
- case Openssl_Hash_RIPEMD160:
- RIPEMD160_File(pFile, output, outlength);
- return true;
}
return false;
diff --git a/extension/sdk/smsdk_config.h b/extension/sdk/smsdk_config.h
index 96fd047..658b76a 100644
--- a/extension/sdk/smsdk_config.h
+++ b/extension/sdk/smsdk_config.h
@@ -40,7 +40,7 @@
/* Basic information exposed publicly */
#define SMEXT_CONF_NAME "NEO cURL Extension"
#define SMEXT_CONF_DESCRIPTION "NEO cURL Extension"
-#define SMEXT_CONF_VERSION "2.0.0.0"
+#define SMEXT_CONF_VERSION "2.0.1"
#define SMEXT_CONF_AUTHOR "https://sappho.io - formerly ben"
#define SMEXT_CONF_URL "https://sappho.io - formerly maintained by http://www.ZombieX2.net/"
#define SMEXT_CONF_LOGTAG "NEO cURL"
diff --git a/extension/sdk/smsdk_ext.cpp b/extension/sdk/smsdk_ext.cpp
index 031ef10..6d74cc5 100644
--- a/extension/sdk/smsdk_ext.cpp
+++ b/extension/sdk/smsdk_ext.cpp
@@ -289,7 +289,6 @@ void SDKExtension::SDK_OnAllLoaded()
void SDKExtension::SDK_OnDependenciesDropped(void)
{
}
-
#if defined SMEXT_CONF_METAMOD
PluginId g_PLID = 0; /**< Metamod plugin ID */