Code snippets for "goto hell" blog post at http://www.apokrupto.com/blog-1/2016/3/17/9y5wmrds7ar9mw8o7q6pyx5c4yi743
Last active
June 11, 2016 12:40
-
-
Save warren-gavin/6b4ef516634e061b405e2f941873a089 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
static OSStatus SSLVerifySignedServerKeyExchange() { | |
err = (ReadyHash(&SSLHashSHA1, &hashCtx) != 0) && | |
(SSLHashSHA1.Update(&hashCtx, &clientRandom) != 0) && | |
(SSLHashSHA1.Update(&hashCtx, &serverRandom) != 0) && | |
(SSLHashSHA1.Update(&hashCtx, &signedParams) != 0) && | |
(SSLHashSHA1.final(&hashCtx, &hashOut) != 0); | |
freeBuffer(&hashCtx); | |
return err; | |
} |
This file contains hidden or 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
bool_t someFunction() { | |
char *c = NULL; | |
int *i = NULL; | |
int *j = NULL; | |
c = malloc(10); | |
if (NULL == c) { | |
/* Handle failure and exit */ | |
} | |
i = malloc(10 * sizeof(*i)); | |
if (NULL == i) { | |
/* Free c, handle failure and exit */ | |
} | |
j = malloc(10 * sizeof(*j)); | |
if (NULL == j) { | |
/* Free c, free i, handle failure and exit */ | |
} | |
return true | |
} |
This file contains hidden or 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
static OSStatus SSLVerifySignedServerKeyExchange() { | |
if ((err = ReadyHash(&SSLHashSHA1, &hashCtx)) != 0) { | |
return err; | |
} | |
if ((err = SSLHashSHA1.Update(&hashCtx, &clientRandom)) != 0) { | |
freeBuffer(&hashCtx); | |
return err; | |
} | |
if ((err = SSLHashSHA1.Update(&hashCtx, &serverRandom)) != 0) { | |
freeBuffer(&hashCtx); | |
return err; | |
} | |
if ((err = SSLHashSHA1.Update(&hashCtx, &signedParams)) != 0) { | |
freeBuffer(&hashCtx); | |
return err; | |
} | |
if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0) { | |
freeBuffer(&hashCtx); | |
return err; | |
} | |
freeBuffer(&hashCtx); | |
return err; | |
} |
This file contains hidden or 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
#define FAIL() do { ret = false; goto cleanup; } while(0) | |
bool_t someFunction() { | |
bool_t ret = true; | |
char *c = NULL; | |
int *i = NULL; | |
int *j = NULL; | |
c = malloc(10); | |
if (NULL == c) { | |
FAIL(); | |
} | |
i = malloc(10 * sizeof(*i)); | |
if (NULL == i) { | |
FAIL(); | |
} | |
j = malloc(10 * sizeof(*j)); | |
if (NULL == j) { | |
FAIL(); | |
} | |
cleanup: | |
free(c); | |
free(i); | |
free(j); | |
return ret; | |
} |
This file contains hidden or 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
bool_t checkForSomethingReallyImportant(void) { | |
if (isThatImportantThingOk()) { | |
return true; | |
} | |
return true; | |
return false; | |
} |
This file contains hidden or 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
bool_t checkForSomethingReallyImportant(void) { | |
if (isThatImportantThingOk()) | |
return true; | |
return true; | |
return false; | |
} |
This file contains hidden or 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
static OSStatus SSLVerifySignedServerKeyExchange() { | |
if ((err = ReadyHash(&SSLHashSHA1, &hashCtx)) != 0) { | |
if ((err = SSLHashSHA1.Update(&hashCtx, &clientRandom)) != 0) { | |
if ((err = SSLHashSHA1.Update(&hashCtx, &serverRandom)) != 0) { | |
// ... | |
} | |
} | |
} | |
freeBuffer(&hashCtx); | |
return err; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment