Skip to content

Commit

Permalink
Fix various issues detected by static analysis
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Rische <jrische@redhat.com>
  • Loading branch information
jrisc committed Aug 6, 2024
1 parent d7be530 commit 07402f9
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/client/gpm_accept_sec_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ OM_uint32 gpm_accept_sec_context(OM_uint32 *minor_status,
if (outbuf) {
*output_token = *outbuf;
free(outbuf);
outpuf = NULL;
}
if (ret_flags) {
*ret_flags = ctx->ctx_flags;
Expand Down
1 change: 1 addition & 0 deletions src/gp_creds.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ uint32_t gp_add_krb5_creds(uint32_t *min,
gss_release_cred(&discard, &user_cred);
gss_release_name(&discard, &target_name);
gss_delete_sec_context(&discard, &initiator_context, NULL);
gss_delete_sec_context(&discard, &acceptor_context, NULL);
gss_release_buffer(&discard, &init_token);
gss_release_buffer(&discard, &accept_token);
gss_release_name(&discard, &req_name);
Expand Down
2 changes: 2 additions & 0 deletions src/gp_rpc_init_sec_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ int gp_init_sec_context(struct gp_call_ctx *gpcall,
};
uint32_t gccn_before = 0;
uint32_t gccn_after = 0;
uint32_t discard;
int ret;

isca = &arg->init_sec_context;
Expand Down Expand Up @@ -192,6 +193,7 @@ int gp_init_sec_context(struct gp_call_ctx *gpcall,

GPRPCDEBUG(gssx_res_init_sec_context, iscr);

gss_delete_sec_context(&discard, &ctx, NULL);
gss_release_name(&ret_min, &target_name);
gss_release_oid(&ret_min, &mech_type);
gss_release_cred(&ret_min, &ich);
Expand Down
5 changes: 3 additions & 2 deletions tests/interposetest.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ void run_server(struct aproc *data)
uint32_t ret_min;
gss_ctx_id_t context_handle = GSS_C_NO_CONTEXT;
gss_cred_id_t cred_handle = GSS_C_NO_CREDENTIAL;
gss_name_t src_name;
gss_name_t src_name = GSS_C_NO_NAME;
gss_buffer_desc out_token = GSS_C_EMPTY_BUFFER;
gss_cred_id_t deleg_cred = GSS_C_NO_CREDENTIAL;
gss_OID_set mech_set = GSS_C_NO_OID_SET;
Expand Down Expand Up @@ -591,7 +591,8 @@ void run_server(struct aproc *data)
goto done;
}

fprintf(stdout, "Server, RECV: %s\n", (char *)out_token.value);
fprintf(stdout, "Server, RECV: %*s\n", out_token.length,
(char *)out_token.value);

gss_release_buffer(&ret_min, &out_token);

Expand Down
2 changes: 1 addition & 1 deletion tests/t_accept.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main(int argc, const char *argv[])
gss_ctx_id_t context_handle = GSS_C_NO_CONTEXT;
gss_buffer_desc in_token = GSS_C_EMPTY_BUFFER;
gss_buffer_desc out_token = GSS_C_EMPTY_BUFFER;
gss_name_t src_name;
gss_name_t src_name = GSS_C_NO_NAME;
uint32_t ret_maj;
uint32_t ret_min;
int ret = -1;
Expand Down
35 changes: 21 additions & 14 deletions tests/userproxytest.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,19 @@ int mock_activation_sockets(void)
unlink(addr.sun_path);

fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == -1) return -1;
if (fd == -1) {
ret = -1;
goto done;
}

ret = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
if (ret == -1) return -1;
if (ret == -1) goto done;

ret = listen(fd, 1);
if (ret == -1) return -1;
if (ret == -1) goto done;

done:
if (ret == -1) close(fd);
return 0;
}

Expand Down Expand Up @@ -75,19 +80,19 @@ int wait_and_check_output(int outfd, int timeout)
useconds_t interval = 100 * 1000; /* 100 msec */
char outbuf[1024];
char *line;
FILE *out;
int ret;
FILE *out = NULL;
int err, ret = -1;

/* make pipe non blocking */
ret = fcntl(outfd, F_SETFL, O_NONBLOCK);
if (ret) return -1;
err = fcntl(outfd, F_SETFL, O_NONBLOCK);
if (err) goto done;

out = fdopen(outfd, "r");
if (!out) return -1;
if (!out) goto done;

while (now < start + timeout) {
ret = usleep(interval);
if (ret) return -1;
err = usleep(interval);
if (err) goto done;

line = fgets(outbuf, 1023, out);
if (line) {
Expand All @@ -101,13 +106,15 @@ int wait_and_check_output(int outfd, int timeout)
now = time(NULL);
}

fclose(out);

for (int i = 0; checks[i].match != NULL; i++) {
if (checks[i].matched == false) return -1;
if (checks[i].matched == false) goto done;
}

return 0;
ret = 0;

done:
if (out) fclose(out);
return ret;
}

int child(int outpipe[])
Expand Down

0 comments on commit 07402f9

Please sign in to comment.