Skip to content

Instantly share code, notes, and snippets.

@warren-gavin
Last active June 11, 2016 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warren-gavin/6b4ef516634e061b405e2f941873a089 to your computer and use it in GitHub Desktop.
Save warren-gavin/6b4ef516634e061b405e2f941873a089 to your computer and use it in GitHub Desktop.
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;
}
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
}
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;
}
#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;
}
bool_t checkForSomethingReallyImportant(void) {
if (isThatImportantThingOk()) {
return true;
}
return true;
return false;
}
bool_t checkForSomethingReallyImportant(void) {
if (isThatImportantThingOk())
return true;
return true;
return false;
}
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