On closer examination, I discover that the buffer populated by the
information returned by gethostbyname is actually unused. Because of
this, a better patch is to just remove the code. Here is such patch.
diff -Nru /tmp/mlTJKtoRzs/cpqarrayd-2.2/cpqarrayd.c
/tmp/2QGhMOf0YJ/cpqarrayd-2.2/cpqarrayd.c
--- /tmp/mlTJKtoRzs/cpqarrayd-2.2/cpqarrayd.c 2008-05-22 22:13:25.000000000
+0200
+++ /tmp/2QGhMOf0YJ/cpqarrayd-2.2/cpqarrayd.c 2008-05-22 22:13:25.000000000
+0200
@@ -131,7 +132,6 @@
int result, i;
FILE *pidfile;
struct sigaction myhandler;
- char *buffer;
struct hostent *myhost;
struct utsname *myhostname;
@@ -191,24 +191,6 @@
printf (" [%2d] Controller type '%s' at %s\n",i,
ctrls_found[i].ctrl_devicename,ctrls_found[i].devicefile);
}
- /* get ip of current machine for traps */
- buffer = (char *)malloc(HOST_NAME_MAX + 1);
- buffer[0] = '\0';
- if (gethostname(buffer, HOST_NAME_MAX + 1) == 0) {
- /* It is unspecified whether a truncated hostname will be NUL-terminated.
*/
- buffer[HOST_NAME_MAX] = '\0';
- myhost = gethostbyname(buffer);
- myip = ((unsigned char) myhost->h_addr_list[0][3] << 24) +
- ((unsigned char) myhost->h_addr_list[0][2] << 16) +
- ((unsigned char) myhost->h_addr_list[0][1] << 8) +
- ((unsigned char) myhost->h_addr_list[0][0]);
- }
- else {
- perror("gethostname");
- strncpy(buffer, "(none)", HOST_NAME_MAX);
- buffer[HOST_NAME_MAX] = '\0';
- }
-
/* test for trap destinations */
if (opts.debug) {
for (i=0; i<opts.nr_traphosts; i++) {
@@ -258,11 +240,8 @@
/* END OF ADDITIONAL CODE */
}
- /* buffer = (char *)malloc(1024); */
- /* sprintf (buffer, "cpqarrayd[%d]\0", getpid); */
openlog ("cpqarrayd", LOG_CONS, LOG_USER);
syslog(LOG_INFO, "Logging Enabled...");
- /* free(buffer); */
while (keeprunning) {
status_check(opts);
Happy hacking,
--
Petter Reinholdtsen
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]