summaryrefslogtreecommitdiff
path: root/imap/src/c-client/auth_oa2.c
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2021-08-28 00:41:09 -0600
committerEduardo Chappa <chappa@washington.edu>2021-08-28 00:41:09 -0600
commit5431d789f6a736924230ff3e51c14e0db441bdb6 (patch)
treee005e44b755c855d38c3c1d2ffffd1a6fd952dab /imap/src/c-client/auth_oa2.c
parentd2ae2bad36529e3381a642d85947d1fd00fc3ffc (diff)
downloadalpine-5431d789f6a736924230ff3e51c14e0db441bdb6.tar.xz
* Fix of more memory leaks and a crash due to incorrect freeing of memory, introduced
in commit 8961761e0b3c7b3cc11a00f6ac6ebf7a29bc5a10
Diffstat (limited to 'imap/src/c-client/auth_oa2.c')
-rw-r--r--imap/src/c-client/auth_oa2.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/imap/src/c-client/auth_oa2.c b/imap/src/c-client/auth_oa2.c
index 2f52c4f2..9081a1e3 100644
--- a/imap/src/c-client/auth_oa2.c
+++ b/imap/src/c-client/auth_oa2.c
@@ -25,7 +25,9 @@ AUTHENTICATOR auth_oa2 = {
};
#define OAUTH2_USER "user="
+#define OAUTH2_USER_LEN (5) /* strlen(OAUTH2_USER) */
#define OAUTH2_BEARER "auth=Bearer "
+#define OAUTH2_BEARER_LEN (12) /* strlen(OAUTH2_BEARER) */
/* Client authenticator
* Accepts: challenger function
@@ -142,8 +144,8 @@ long auth_oauth2_client (authchallenge_t challenger,authrespond_t responder, cha
ret = base ? NIL : LONGT; /* will get a BAD response back */
}
else {
- unsigned long rlen = strlen(OAUTH2_USER) + strlen(user)
- + strlen(OAUTH2_BEARER) + strlen(oauth2.access_token) + 1 + 2;
+ unsigned long rlen = OAUTH2_USER_LEN + OAUTH2_BEARER_LEN + 2
+ + strlen(user) + strlen(oauth2.access_token) + 1;
char *response = (char *) fs_get (rlen + 1);
sprintf(response, "%s%s\001%s%s\001\001", OAUTH2_USER, user, OAUTH2_BEARER, oauth2.access_token);
if ((*responder) (stream,base,response,rlen)) {
@@ -157,13 +159,8 @@ long auth_oauth2_client (authchallenge_t challenger,authrespond_t responder, cha
* Refresh Token has expired somehow, we invalidate it if we
* reach *trial to 3. This forces the process to restart later on.
*/
- if(*trial == 3){
- if(oauth2.param[OA2_State].value)
- fs_give((void **) &oauth2.param[OA2_State].value);
- fs_give((void **) &oauth2.param[OA2_RefreshToken].value);
- fs_give((void **) &oauth2.access_token);
+ if(*trial == 3)
oauth2.expiration = 0L;
- }
}
}
fs_give ((void **) &response);