diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-29 21:34:40 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-29 21:34:40 +0000 |
commit | 33d765917eabeb4b664c1b0681d52185920def72 (patch) | |
tree | 2c9e2a65aca18a034daada72599fc6531adae7e1 /protocols/Gadu-Gadu/src/oauth.cpp | |
parent | a66281d8453edde56145e032e8d38db91580ba08 (diff) |
no more mir_strncat in GG
git-svn-id: http://svn.miranda-ng.org/main/trunk@13901 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Gadu-Gadu/src/oauth.cpp')
-rw-r--r-- | protocols/Gadu-Gadu/src/oauth.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp index 7990753277..14fc85d6ce 100644 --- a/protocols/Gadu-Gadu/src/oauth.cpp +++ b/protocols/Gadu-Gadu/src/oauth.cpp @@ -219,19 +219,15 @@ int oauth_sign_request(LIST<OAUTHPARAMETER> ¶ms, const char *httpmethod, con return 0;
}
-char *oauth_generate_nonce()
+char* oauth_generate_nonce()
{
- char timestamp[22], randnum[16];
- mir_snprintf(timestamp, SIZEOF(timestamp), "%ld", time(NULL));
+ char randnum[16];
CallService(MS_UTILS_GETRANDOM, (WPARAM)sizeof(randnum), (LPARAM)randnum);
- int strSizeB = int(mir_strlen(timestamp) + sizeof(randnum));
- ptrA str((char *)mir_calloc(strSizeB + 1));
- mir_strcpy(str, timestamp);
- mir_strncat(str, randnum, sizeof(randnum));
+ CMStringA str(FORMAT, "%ld%s", time(NULL), randnum);
BYTE digest[16];
- mir_md5_hash((BYTE*)(char*)str, strSizeB, digest);
+ mir_md5_hash((BYTE*)str.GetString(), str.GetLength(), digest);
return bin2hex(digest, sizeof(digest), (char *)mir_alloc(32 + 1));
}
@@ -240,7 +236,7 @@ char *oauth_auth_header(const char *httpmethod, const char *url, OAUTHSIGNMETHOD const char *token, const char *token_secret)
{
int i, size;
- char *res, timestamp[22], *nonce;
+ char *res, timestamp[22];
if (httpmethod == NULL || url == NULL) return NULL;
@@ -254,9 +250,7 @@ char *oauth_auth_header(const char *httpmethod, const char *url, OAUTHSIGNMETHOD };
mir_snprintf(timestamp, SIZEOF(timestamp), "%ld", time(NULL));
oauth_setparam(oauth_parameters, "oauth_timestamp", timestamp);
- nonce = oauth_generate_nonce();
- oauth_setparam(oauth_parameters, "oauth_nonce", nonce);
- mir_free(nonce);
+ oauth_setparam(oauth_parameters, "oauth_nonce", ptrA(oauth_generate_nonce()));
if (token != NULL && *token)
oauth_setparam(oauth_parameters, "oauth_token", token);
|