Skip to content

Commit

Permalink
Change: Apply suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Oct 21, 2022
1 parent 6ca43e3 commit bf8c1bf
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 29 deletions.
6 changes: 3 additions & 3 deletions misc/ipc_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ char *
ipc_pipe_retrieve (struct ipc_pipe_context *context)
{
char *result = NULL;
int rfd, rr, pf;
int rfd, pf;
rfd = context->fd[0];
pf = fcntl (rfd, F_GETFL, 0);
if (pf < 0 && errno != EBADF)
Expand All @@ -73,8 +73,8 @@ ipc_pipe_retrieve (struct ipc_pipe_context *context)
fcntl (rfd, F_SETFL, pf | O_NONBLOCK);
if ((result = calloc (1, IPC_MAX_BUFFER)) == NULL)
return NULL;
rr = read (rfd, result, IPC_MAX_BUFFER);
if (rr > 0)

if (read (rfd, result, IPC_MAX_BUFFER) > 0)
{
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion nasl/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ nasl_exec (lex_ctxt *lexic, tree_cell *st)
s3 = g_malloc0 (sz + 1);
if (p - p1 > 0)
memcpy (s3, p1, p - p1);
if (sz > p - p1 && p != NULL)
if (p != NULL && sz > p - p1)
memcpy (s3 + (p - p1), p + len2, sz - (p - p1));
}
ret = alloc_typed_cell (flag);
Expand Down
23 changes: 11 additions & 12 deletions nasl/lint.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,7 @@ nasl_lint (lex_ctxt *lexic, tree_cell *st)
if (desc_block != NULL && desc_block != FAKE_CELL)
{
/* FAKE_CELL if success, NULL otherwise which counts as error */
ret = check_description_block (lexic_aux, desc_block);
if (ret == NULL)
if (check_description_block (lexic_aux, desc_block) == NULL)
{
inc_errors_cnt ();
}
Expand All @@ -859,17 +858,17 @@ nasl_lint (lex_ctxt *lexic, tree_cell *st)
make_call_func_list (lexic_aux, st, &called_funcs);

/* Loads all defined functions. */
ret =
nasl_lint_def (lexic_aux, st, lint_mode, &include_files, &func_fnames_tab,
err_fname, &called_funcs, &def_func_tree);
if (ret == NULL)
if (nasl_lint_def (lexic_aux, st, lint_mode, &include_files, &func_fnames_tab,
err_fname, &called_funcs, &def_func_tree)
== NULL)
{
inc_errors_cnt ();
}
/* Check if a called function was defined. */
ret = nasl_lint_call (lexic_aux, st, &include_files, &func_fnames_tab,
err_fname, &called_funcs, &def_func_tree);
if (ret == NULL)

if (nasl_lint_call (lexic_aux, st, &include_files, &func_fnames_tab,
err_fname, &called_funcs, &def_func_tree)
== NULL)
{
inc_errors_cnt ();
}
Expand All @@ -886,9 +885,9 @@ nasl_lint (lex_ctxt *lexic, tree_cell *st)

/* Now check that each function was loaded just once. */
lint_mode = 0;
ret = nasl_lint_def (lexic, st, lint_mode, &include_files, &func_fnames_tab,
err_fname, &called_funcs, &def_func_tree);
if (ret == NULL)
if (nasl_lint_def (lexic, st, lint_mode, &include_files, &func_fnames_tab,
err_fname, &called_funcs, &def_func_tree)
== NULL)
{
inc_errors_cnt ();
}
Expand Down
5 changes: 2 additions & 3 deletions nasl/nasl_host.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,15 +554,14 @@ nasl_same_host (lex_ctxt *lexic)

for (i = 0; i < 2; i++)
g_free (a[i]);
// if (cmp_hostname)
// {

for (i = 0; i < 2; i++)
{
for (j = 0; j < names_nb[i]; j++)
g_free (names[i][j]);
g_free (names[i]);
}
// }

return retc;
}

Expand Down
6 changes: 2 additions & 4 deletions nasl/nasl_ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,6 @@ nasl_ssh_login_interactive (lex_ctxt *lexic)
int tbl_slot;
int session_id;
ssh_session session;
int rc;
const char *s = NULL;
int methods;
int verbose;
Expand Down Expand Up @@ -1064,8 +1063,8 @@ nasl_ssh_login_interactive (lex_ctxt *lexic)
{
/* Our strategy for kbint is to send the password to the first
prompt marked as non-echo. */
rc = ssh_userauth_kbdint (session, NULL, NULL);
while (rc == SSH_AUTH_INFO)

while (ssh_userauth_kbdint (session, NULL, NULL) == SSH_AUTH_INFO)
{
int n, nprompt;
char echoflag;
Expand All @@ -1091,7 +1090,6 @@ nasl_ssh_login_interactive (lex_ctxt *lexic)
if (s && *s && !echoflag && !found_prompt)
goto leave;
}
rc = ssh_userauth_kbdint (session, NULL, NULL);
}
if (verbose)
g_message (
Expand Down
9 changes: 3 additions & 6 deletions src/openvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,10 @@ openvas (int argc, char *argv[], char *env[])
}
tzset ();

err = init_logging ();
if (err != 0)
if (init_logging () != 0)
return EXIT_FAILURE;

err = init_sentry ();
if (!err)
if (!init_sentry ())
{
g_message ("Sentry is enabled. This can log sensitive information.");
}
Expand Down Expand Up @@ -608,8 +606,7 @@ openvas (int argc, char *argv[], char *env[])
globals = g_malloc0 (sizeof (struct scan_globals));
globals->scan_id = g_strdup (get_scan_id ());

err = attack_network_init (globals, config_file);
if (err != 0)
if (attack_network_init (globals, config_file) != 0)
{
destroy_scan_globals (globals);
return EXIT_FAILURE;
Expand Down

0 comments on commit bf8c1bf

Please sign in to comment.