Skip to content

Instantly share code, notes, and snippets.

@nezza
Created July 20, 2017 12:57
Show Gist options
  • Save nezza/46b752d5715a28e5b2831da0b2213faa to your computer and use it in GitHub Desktop.
Save nezza/46b752d5715a28e5b2831da0b2213faa to your computer and use it in GitHub Desktop.
#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