Hi guys,
could you please review and apply the attached patches which fix compilation
with gcc 4.6? It is mostly about unused variables but I'm not sure about the
proper use of errno with regards to concurrency.
thanks a lot,
Stephan
Index: src/attack.c
===================================================================
--- src/attack.c.orig 2011-04-11 09:29:40.000000000 +0200
+++ src/attack.c 2011-05-21 18:19:14.403771878 +0200
@@ -939,7 +939,6 @@ attack_network (struct arglist *globals)
{
int max_hosts = 0;
int num_tested = 0;
- int host_pending = 0;
char hostname[1024];
char *hostlist;
struct in6_addr host_ip;
@@ -1139,7 +1138,6 @@ attack_network (struct arglist *globals)
}
}
- host_pending = 0;
memcpy (&addrs.ip6, &host_ip, sizeof (struct in6_addr));
/* Do we have the right to test this host ? */
@@ -1156,9 +1154,7 @@ attack_network (struct arglist *globals)
int s;
char *MAC = NULL;
int mac_err = -1;
- struct in_addr addr;
- addr.s_addr = host_ip.s6_addr32[3];
if (preferences_use_mac_addr (preferences)
&& v6_is_local_ip (&host_ip))
{
Index: src/nasl_plugins.c
===================================================================
--- src/nasl_plugins.c.orig 2011-04-11 09:29:40.000000000 +0200
+++ src/nasl_plugins.c 2011-05-21 18:33:13.242467099 +0200
@@ -29,6 +29,7 @@
* @brief The nasl - plugin class. Loads or launches nasl- plugins.
*/
+#include <errno.h>
#include <stdio.h> /* for fprintf() */
#include <unistd.h> /* for close() */
#include <signal.h> /* for SIGTERM */
@@ -252,10 +253,17 @@ nasl_thread (struct arglist *g_args)
int nice_retval;
if (preferences_benice (NULL))
- nice_retval = nice (-5);
+ {
+ errno = 0;
+ nice_retval = nice (-5);
+ if (nice_retval == -1 && errno != 0)
+ {
// @todo: Check value of nice_retval to see if it was successful.
// Keep in mind that even -1 can mean success here; see man page of nice
// for details.
+ log_write ("Unable to renice process: %d", errno);
+ }
+ }
/* XXX ugly hack */
soc = dup2 (soc, 4);
Index: src/openvassd.c
===================================================================
--- src/openvassd.c.orig 2011-04-11 09:29:40.000000000 +0200
+++ src/openvassd.c 2011-05-21 18:38:01.994425571 +0200
@@ -40,6 +40,7 @@
* OpenVAS Scanner main module, runs the scanner.
*/
+#include <errno.h>
#include <string.h> /* for strchr() */
#include <stdio.h> /* for fprintf() */
#include <stdlib.h> /* for atoi() */
@@ -428,11 +429,17 @@ scanner_thread (struct arglist *globals)
/* Everyone runs with a nicelevel of 10 */
if (preferences_benice (prefs))
- nice_retval = nice (10);
+ {
+ errno = 0;
+ nice_retval = nice (10);
+ if (nice_retval == -1 && errno != 0)
+ {
// @todo: Check value of nice_retval to see if it was successful.
// Keep in mind that even -1 can mean success here; see man page of nice
// for details.
-
+ log_write ("Unable to renice process: %d", errno);
+ }
+ }
openvas_signal (SIGCHLD, sighand_chld);
#if 1
/* To let some time to attach a debugger to the child process */
Index: src/oval_plugins.c
===================================================================
--- src/oval_plugins.c.orig 2011-04-11 09:29:40.000000000 +0200
+++ src/oval_plugins.c 2011-05-21 18:45:30.420070631 +0200
@@ -360,7 +360,6 @@ oval_plugin_add (char *folder, char *nam
gchar *filebuffer = NULL;
gsize length = 0;
gchar *descriptions = NULL;
- gchar *description = NULL;
int i;
if (plugin_list != NULL)
@@ -437,11 +436,10 @@ oval_plugin_add (char *folder, char *nam
descriptions = g_strjoinv (NULL, title_array);
if (strlen (descriptions) > 3100)
{
- description =
- g_strconcat
+ nvti_set_description (first_plugin, g_strconcat
("This OVAL file contains the following definitions:\n",
g_strndup (descriptions, 3100),
- "\n(list cut due to memory limitations)", NULL);
+ "\n(list cut due to memory limitations)", NULL));
}
else
{
Index: src/ntp_11.c
===================================================================
--- src/ntp_11.c.orig 2011-04-11 09:29:40.000000000 +0200
+++ src/ntp_11.c 2011-05-21 18:47:56.270378747 +0200
@@ -812,11 +812,11 @@ ntp_1x_send_dependencies (struct arglist
while (plugins->next)
{
struct arglist *args = plugins->value;
- struct arglist *d, *deps;
+ struct arglist *deps;
if (!args)
goto nxt;
- d = deps = plug_get_deps (args);
+ deps = plug_get_deps (args);
if (deps == NULL)
goto nxt;
Index: src/preferences.c
===================================================================
--- src/preferences.c.orig 2011-04-11 09:29:40.000000000 +0200
+++ src/preferences.c 2011-05-21 18:53:03.421326843 +0200
@@ -452,7 +452,6 @@ preferences_benice (struct arglist *pref
int
preferences_drop_privileges (struct arglist *preferences, char *oid)
{
- char *pref;
int ret = 0;
if (preferences == NULL)
@@ -464,7 +463,6 @@ preferences_drop_privileges (struct argl
ret = 1;
}
- pref = arg_get_value (preferences, "drop_privileges");
return ret;
}
Index: src/sighand.c
===================================================================
--- src/sighand.c.orig 2011-04-11 09:29:40.000000000 +0200
+++ src/sighand.c 2011-05-21 18:57:59.751739204 +0200
@@ -49,6 +49,8 @@ let_em_die (int pid)
int status, x;
x = waitpid (pid, &status, WNOHANG);
+ if (x == -1)
+ log_write ("Unable to wait for state change of process %d", pid);
}
Index: src/shared_socket.c
===================================================================
--- src/shared_socket.c.orig 2011-04-11 09:29:40.000000000 +0200
+++ src/shared_socket.c 2011-05-21 19:01:40.680977694 +0200
@@ -101,7 +101,7 @@ openvassd_shared_socket_register (int so
e = internal_recv (soc, &buffer, &bufsz, &type);
if ((type & INTERNAL_COMM_MSG_SHARED_SOCKET) == 0
- || (type & INTERNAL_COMM_SHARED_SOCKET_DORECVMSG) == 0)
+ || (type & INTERNAL_COMM_SHARED_SOCKET_DORECVMSG) == 0 || e == -1)
{
log_write ("shared_socket_register(): Error - unexpected message %d\n",
type);
Index: src/manage_sql.c
===================================================================
--- src/manage_sql.c.orig 2011-04-15 15:30:00.000000000 +0200
+++ src/manage_sql.c 2011-05-21 19:46:24.071319484 +0200
@@ -12061,12 +12061,10 @@ manage_report (report_t report, report_f
{
iterator_t formats;
const char *uuid_format;
- char *uuid_report;
gchar *script, *script_dir;
/* Setup file names. */
- uuid_report = report_uuid (report);
init_report_format_iterator (&formats, report_format, 1, NULL);
if (next (&formats) == FALSE)
{
@@ -12361,12 +12359,10 @@ manage_send_report (report_t report, rep
{
iterator_t formats;
const char *uuid_format;
- char *uuid_report;
gchar *script, *script_dir;
/* Setup file names. */
- uuid_report = report_uuid (report);
init_report_format_iterator (&formats, report_format, 1, NULL);
if (next (&formats) == FALSE)
{
@@ -21061,7 +21057,7 @@ months_between (time_t time1, time_t tim
{
struct tm broken1, *broken2;
int same_year, same_month, same_day, same_hour, same_minute, same_second;
- int year1_less, month1_less, day1_less, hour1_less, minute1_less;
+ int month1_less, day1_less, hour1_less, minute1_less;
int second1_less;
assert (time1 < time2);
@@ -21076,7 +21072,6 @@ months_between (time_t time1, time_t tim
same_minute = (broken1.tm_min == broken2->tm_min);
same_second = (broken1.tm_sec == broken2->tm_sec);
- year1_less = (broken1.tm_year < broken2->tm_year);
month1_less = (broken1.tm_mon < broken2->tm_mon);
day1_less = (broken1.tm_mday < broken2->tm_mday);
hour1_less = (broken1.tm_hour < broken2->tm_hour);
Index: src/omp.c
===================================================================
--- src/omp.c.orig 2011-04-15 15:30:03.000000000 +0200
+++ src/omp.c 2011-05-21 19:51:28.717059464 +0200
@@ -10092,7 +10092,7 @@ omp_xml_handle_end_element (/*@unused@*/
}
else
{
- int fail = 0, first = 1;
+ int fail = 0;
/** @todo It'd probably be better to allow only one
* modification at a time, that is, one parameter or one of
@@ -10115,8 +10115,6 @@ omp_xml_handle_end_element (/*@unused@*/
"Task %s could not be modified",
modify_task_data->task_id);
}
- else
- first = 0;
}
if (fail == 0 && modify_task_data->name)
@@ -10133,8 +10131,6 @@ omp_xml_handle_end_element (/*@unused@*/
"Task %s could not be modified",
modify_task_data->task_id);
}
- else
- first = 0;
}
if (fail == 0 && modify_task_data->comment)
@@ -10151,8 +10147,6 @@ omp_xml_handle_end_element (/*@unused@*/
"Task %s could not be modified",
modify_task_data->task_id);
}
- else
- first = 0;
}
if (fail == 0 && modify_task_data->escalator_id)
@@ -10162,7 +10156,6 @@ omp_xml_handle_end_element (/*@unused@*/
if (strcmp (modify_task_data->escalator_id, "0") == 0)
{
set_task_escalator (task, 0);
- first = 0;
}
else if ((fail = find_escalator
(modify_task_data->escalator_id,
@@ -10186,7 +10179,6 @@ omp_xml_handle_end_element (/*@unused@*/
else
{
set_task_escalator (task, escalator);
- first = 0;
}
}
@@ -10197,7 +10189,6 @@ omp_xml_handle_end_element (/*@unused@*/
if (strcmp (modify_task_data->schedule_id, "0") == 0)
{
set_task_schedule (task, 0);
- first = 0;
}
else if ((fail = find_schedule
(modify_task_data->schedule_id,
@@ -10221,7 +10212,6 @@ omp_xml_handle_end_element (/*@unused@*/
else
{
set_task_schedule (task, schedule);
- first = 0;
}
}
@@ -10232,7 +10222,6 @@ omp_xml_handle_end_element (/*@unused@*/
if (strcmp (modify_task_data->slave_id, "0") == 0)
{
set_task_slave (task, 0);
- first = 0;
}
else if ((fail = find_slave
(modify_task_data->slave_id,
@@ -10256,7 +10245,6 @@ omp_xml_handle_end_element (/*@unused@*/
else
{
set_task_slave (task, slave);
- first = 0;
}
}
Index: omp/omp.c
===================================================================
--- omp/omp.c.orig 2011-05-04 08:22:37.000000000 +0200
+++ omp/omp.c 2011-05-21 19:57:30.932683592 +0200
@@ -2331,7 +2331,6 @@ int
omp_get_system_reports (gnutls_session_t* session, const char* name, int brief,
entity_t *reports)
{
- int ret;
const char *status_code;
if (name)
@@ -2368,7 +2367,6 @@ omp_get_system_reports (gnutls_session_t
return -1;
}
if (status_code[0] == '2') return 0;
- ret = (int) strtol (status_code, NULL, 10);
free_entity (*reports);
if (errno == ERANGE) return -1;
return 1;
Index: misc/network.c
===================================================================
--- misc/network.c.orig 2011-05-04 08:22:37.000000000 +0200
+++ misc/network.c 2011-05-21 20:02:38.399335237 +0200
@@ -25,6 +25,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdarg.h>
@@ -133,10 +134,15 @@ renice_myself ()
if (nice (0) >= 10)
return;
pid = cpid;
+ errno = 0;
renice_result = nice (1);
+ if (renice_result == -1 && errno != 0)
+ {
// @todo: Check value if renice_result to see if it was successful.
// Keep in mind that even -1 can mean success here; see man page of nice
// for details.
+ fprintf (stderr, "Unable to renice process: %d", errno);
+ }
}
}
Index: misc/plugutils.c
===================================================================
--- misc/plugutils.c.orig 2011-05-04 08:22:37.000000000 +0200
+++ misc/plugutils.c 2011-05-21 20:07:05.733422394 +0200
@@ -1550,9 +1550,8 @@ plug_get_key (struct arglist *args, char
socketpair (AF_UNIX, SOCK_STREAM, 0, sockpair);
if ((pid = fork ()) == 0)
{
- int tictac = 0;
int old, soc;
- struct arglist *globals, *preferences = NULL;
+ struct arglist *globals;
close (sockpair[0]);
globals = arg_get_value (args, "globals");
@@ -1565,15 +1564,6 @@ plug_get_key (struct arglist *args, char
arg_set_value (args, "SOCKET", sizeof (gpointer),
GSIZE_TO_POINTER (soc));
- if (globals != NULL)
- preferences = arg_get_value (globals, "preferences");
- if (preferences != NULL)
- {
- char *to = arg_get_value (preferences, "plugins_timeout");
- if (to != NULL)
- tictac = atoi (to);
- }
-
srand48 (getpid () + getppid () + time (NULL)); /* RATS: ignore */
sig_term (_exit);
_______________________________________________
Openvas-devel mailing list
[email protected]
http://lists.wald.intevation.org/mailman/listinfo/openvas-devel