Skip to content

Commit

Permalink
improve some empty struct inits
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmann committed Aug 20, 2024
1 parent d8fb865 commit 6408177
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/api/accounts.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static struct agent_response _getAgentAccountInfosResponse(int type) {
case AGENT_RESPONSE_TYPE_ACCOUNTINFO:
request = getAccountInfoRequest();
break;
default: return (struct agent_response){};
default: return (struct agent_response){0};
}
char* response = communicate(LOCAL_COMM, request);
struct agent_response ret = parseForAgentAccountInfosResponse(response, type);
Expand Down
4 changes: 2 additions & 2 deletions src/oidc-agent/oidc/flows/openid_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ oidc_error_t obtainIssuerConfig(struct oidc_account* account) {

char* getScopesSupportedFor(const char* issuer_url, const char* config_endpoint,
const char* cert_path) {
struct oidc_account account = {};
struct oidc_account account = {0};
account_setIssuerUrl(&account, oidc_strcopy(issuer_url));
account_setConfigEndpoint(&account, oidc_strcopy(config_endpoint));
if (strValid(cert_path)) {
Expand All @@ -84,7 +84,7 @@ char* getScopesSupportedFor(const char* issuer_url, const char* config_endpoint,
char* getProvidersSupportedByMytoken(const char* issuer_url,
const char* config_endpoint,
const char* cert_path) {
struct oidc_account account = {};
struct oidc_account account = {0};
account_setIssuerUrl(&account, oidc_strcopy(issuer_url));
account_setConfigEndpoint(&account, oidc_strcopy(config_endpoint));
if (strValid(cert_path)) {
Expand Down
9 changes: 4 additions & 5 deletions src/utils/crypt/ipcCryptUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ char* decryptForIpc(const char* msg, const unsigned char* key) {
oidc_errno = OIDC_ECRYPMIPC;
return NULL;
}
struct encryptionInfo crypt = {};
crypt.nonce_base64 = nonce_base64;
crypt.encrypted_base64 = encrypted_base64;
crypt.cryptParameter = newCryptParameters();
unsigned char* decryptedMsg =
struct encryptionInfo crypt = {.nonce_base64 = nonce_base64,
.encrypted_base64 = encrypted_base64,
.cryptParameter = newCryptParameters()};
unsigned char* decryptedMsg =
crypt_decryptWithKey(&crypt, msg_len + crypt.cryptParameter.mac_len, key);
secFree(msg_tmp);
return (char*)decryptedMsg;
Expand Down
22 changes: 11 additions & 11 deletions src/utils/uriUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,25 @@ char* getTopHost(const char* uri) {
oidc_setArgNullFuncError(__func__);
return NULL;
}
char* tmp = oidc_strcopy(uri);
char* b = strstr(tmp, "://") + 3;
char* e = strchr(b, '/');
*e = '\0';
e = strrchr(b, '.');
*e = '\0';
char* t = strrchr(b, '.');
if (t!=NULL) {
b=t+1;
char* tmp = oidc_strcopy(uri);
char* b = strstr(tmp, "://") + 3;
char* e = strchr(b, '/');
*e = '\0';
e = strrchr(b, '.');
*e = '\0';
char* t = strrchr(b, '.');
if (t != NULL) {
b = t + 1;
}
char* extracted = oidc_strcopy(b );
char* extracted = oidc_strcopy(b);
secFree(tmp);
return extracted;
}

struct codeState codeStateFromURI(const char* uri) {
if (uri == NULL) {
oidc_setArgNullFuncError(__func__);
return (struct codeState){};
return (struct codeState){0};
}
char* state = extractParameterValueFromUri(uri, "state");
char* code = extractParameterValueFromUri(uri, "code");
Expand Down

0 comments on commit 6408177

Please sign in to comment.