Created
July 20, 2017 12:57
-
-
Save nezza/46b752d5715a28e5b2831da0b2213faa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
char * psdk_authorize(const char *clientid,const char *requestid, char * clientsicret, int wait) { | |
int bufsize = 87 + strlen (clientid) + strlen (requestid); | |
printf("Going to allocate: %d\n", bufsize); | |
char * buff = (char *)malloc(bufsize); | |
int ret = sprintf(buff, "https://my.pcloud.com/oauth2/authorize?client_id=%s&response_type=poll_token&request_id=%s", clientid, requestid); | |
printf("Wrote: %d bytes", ret); | |
return NULL; | |
} | |
char *bigbuf() { | |
uint64_t max = 1024; | |
max *= 1024; | |
max *= 1024; | |
max *= 2; | |
char *foo = malloc(max); | |
for(uint64_t i=0; i < max; i++) { | |
foo[i] = 'a'; | |
} | |
foo[max-1] = 0x00; | |
return foo; | |
} | |
int main(int argc, char* argv[]) { | |
puts("Hello!"); | |
char *clientid = bigbuf(); | |
char *requestid = bigbuf(); | |
if(!clientid || !requestid) { | |
puts("Broken!"); | |
return 1; | |
} | |
puts("Allocated and filled"); | |
psdk_authorize(clientid, requestid, "hello", 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment