rpms/anacron/devel anacron-2.3-hostname.patch, NONE, 1.1 anacron-2.3-memoryleak.patch, NONE, 1.1 anacron-2.3-pie.patch, NONE, 1.1 anacron.spec, 1.25, 1.26

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Tue Oct 10 13:59:01 UTC 2006


Author: mmaslano

Update of /cvs/dist/rpms/anacron/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv1083

Modified Files:
	anacron.spec 
Added Files:
	anacron-2.3-hostname.patch anacron-2.3-memoryleak.patch 
	anacron-2.3-pie.patch 
Log Message:
Anacron is pie executable now.
Fixed some memory leak.
#210020


anacron-2.3-hostname.patch:
 global.h |    1 +
 runjob.c |   17 +++++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

--- NEW FILE anacron-2.3-hostname.patch ---
--- anacron-2.3/runjob.c.hostname	2006-10-04 11:58:55.000000000 +0200
+++ anacron-2.3/runjob.c	2006-10-09 09:43:23.000000000 +0200
@@ -94,6 +94,17 @@
 }
 
 static char *
+hostname()
+{
+    char hostname[MAXHOSTNAME];
+
+    if (gethostname(hostname, MAXHOSTNAME) == 0)
+	return hostname;
+    else 
+	die_e("Can't resolve hostname");
+}
+
+static char *
 mailto()
 {
     char *alias;
@@ -255,9 +266,11 @@
     xwrite(fd, "Content-Type: text/plain; charset=\"");
     xwrite(fd, nl_langinfo(CODESET));
     xwrite(fd, "\"\n");
-    xwrite(fd, "Subject: Anacron job '");
+    xwrite(fd, "Subject: Anacron job for '");
+    xwrite(fd, hostname());
+    xwrite(fd, "' ");
     xwrite(fd, jr->ident);
-    xwrite(fd, "'\n\n");
+    xwrite(fd, "\n");
     jr->mail_header_size = file_size(fd);
 
     pid = xfork();
--- anacron-2.3/global.h.hostname	2006-10-04 11:58:55.000000000 +0200
+++ anacron-2.3/global.h	2006-10-04 11:58:55.000000000 +0200
@@ -33,6 +33,7 @@
 
 /* Mail interface.  (All MTAs should supply this command) */
 #define SENDMAIL "/usr/sbin/sendmail"
+#define MAXHOSTNAME 64
 
 #ifndef PID_FILE
 #define PID_FILE "/var/run/anacron.pid"

anacron-2.3-memoryleak.patch:
 global.h  |   31 +++++++++++++++++++------------
 gregor.c  |    2 +-
 lock.c    |    2 +-
 log.c     |   13 +++++++------
 main.c    |    2 +-
 matchrx.c |   25 +++++++++++++++++++++----
 runjob.c  |    6 +++---
 7 files changed, 53 insertions(+), 28 deletions(-)

--- NEW FILE anacron-2.3-memoryleak.patch ---
--- anacron-2.3/main.c.memoryleak	2006-10-10 15:40:37.000000000 +0200
+++ anacron-2.3/main.c	2006-10-10 15:50:18.000000000 +0200
@@ -540,7 +540,7 @@
     }
 
     if (anacrontab == NULL)
-	anacrontab = strdup(ANACRONTAB);
+	anacrontab = strndup(ANACRONTAB, strlen(ANACRONTAB));
 
     in_background = 0;
 
--- anacron-2.3/global.h.memoryleak	2006-10-10 15:40:37.000000000 +0200
+++ anacron-2.3/global.h	2006-10-10 15:40:37.000000000 +0200
@@ -109,18 +109,25 @@
 /* main.c */
 int xopen(int fd, const char *file_name, int flags);
 void xclose(int fd);
-pid_t xfork();
+pid_t xfork(void);
+
+#ifdef __GNUC__
+#define PRINTF_FORMAT(n, m) \
+   __attribute__ ((format (printf, n, m)))
+#else
+#define PRINTF_FORMAT(n, m)
+#endif
 
 /* log.c */
-void explain(const char *fmt, ...);
-void explain_e(const char *fmt, ...);
-void complain(const char *fmt, ...);
-void complain_e(const char *fmt, ...);
-void die(const char *fmt, ...);
-void die_e(const char *fmt, ...);
-void xdebug(const char *fmt, ...);
-void xdebug_e(const char *fmt, ...);
-void xcloselog();
+void explain(const char *fmt, ...)PRINTF_FORMAT(1,2);
+void explain_e(const char *fmt, ...)PRINTF_FORMAT(1,2);
+void complain(const char *fmt, ...)PRINTF_FORMAT(1,2);
+void complain_e(const char *fmt, ...)PRINTF_FORMAT(1,2);
+void die(const char *fmt, ...)PRINTF_FORMAT(1,2);
+void die_e(const char *fmt, ...)PRINTF_FORMAT(1,2);
+void xdebug(const char *fmt, ...)PRINTF_FORMAT(1,2);
+void xdebug_e(const char *fmt, ...)PRINTF_FORMAT(1,2);
+void xcloselog(void);
 
 #ifdef DEBUG
 #define Debug(args) xdebug args
@@ -131,8 +138,8 @@
 #endif /* not DEBUG */
 
 /* readtab.c */
-void read_tab();
-void arrange_jobs();
+void read_tab(void);
+void arrange_jobs(void);
 
 /* lock.c */
 int consider_job(job_rec *jr);
--- anacron-2.3/gregor.c.memoryleak	2006-10-10 15:40:37.000000000 +0200
+++ anacron-2.3/gregor.c	2006-10-10 15:40:37.000000000 +0200
@@ -25,7 +25,7 @@
 #include <limits.h>
 #include "gregor.h"
 
-const static int
+static const int
 days_in_month[] = {
     31,  /* Jan */
     28,  /* Feb (non-leap) */
--- anacron-2.3/runjob.c.memoryleak	2006-10-10 15:40:37.000000000 +0200
+++ anacron-2.3/runjob.c	2006-10-10 15:40:37.000000000 +0200
@@ -64,8 +64,8 @@
     if (fdin == -1) die_e("Can't open temporary file for reading");
     if (unlink(name)) die_e("Can't unlink temporary file");
     free(name);
-    fcntl(fdout, F_SETFD, 1);    /* set close-on-exec flag */
-    fcntl(fdin, F_SETFD, 1);    /* set close-on-exec flag */
+    fcntl(fdout, F_SETFD, FD_CLOEXEC);    /* set close-on-exec flag */
+    fcntl(fdin, F_SETFD, FD_CLOEXEC);    /* set close-on-exec flag */
 
     jr->input_fd = fdin;
     jr->output_fd = fdout;
@@ -189,7 +189,7 @@
     pid = xfork();
     if (pid == 0)
     {
-	long fdflags;
+	/* long fdflags; */
 
 	/* child */
 	in_background = 1;
--- anacron-2.3/log.c.memoryleak	2000-06-23 02:00:14.000000000 +0200
+++ anacron-2.3/log.c	2006-10-10 15:40:37.000000000 +0200
@@ -35,6 +35,7 @@
  */
 
 #include <unistd.h>
+#include <stdlib.h>
 #include <syslog.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -79,7 +80,7 @@
 }
 
 static void
-log(int priority, const char *fmt, va_list args)
+slog(int priority, const char *fmt, va_list args)
 /* Log a message, described by "fmt" and "args", with the specified
  * "priority". */
 {
@@ -97,7 +98,7 @@
 
 static void
 log_e(int priority, const char *fmt, va_list args)
-/* Same as log(), but also appends an error description corresponding
+/* Same as slog(), but also appends an error description corresponding
  * to "errno". */
 {
     int saved_errno;
@@ -123,7 +124,7 @@
     va_list args;
 
     va_start(args, fmt);
-    log(EXPLAIN_LEVEL, fmt, args);
+    slog(EXPLAIN_LEVEL, fmt, args);
     va_end(args);
 }
 
@@ -145,7 +146,7 @@
     va_list args;
 
     va_start(args, fmt);
-    log(COMPLAIN_LEVEL, fmt, args);
+    slog(COMPLAIN_LEVEL, fmt, args);
     va_end(args);
 }
 
@@ -167,7 +168,7 @@
     va_list args;
 
     va_start(args, fmt);
-    log(COMPLAIN_LEVEL, fmt, args);
+    slog(COMPLAIN_LEVEL, fmt, args);
     va_end(args);
     if (getpid() == primary_pid) complain("Aborted");
 
@@ -199,7 +200,7 @@
     va_list args;
 
     va_start(args, fmt);
-    log(DEBUG_LEVEL, fmt, args);
+    slog(DEBUG_LEVEL, fmt, args);
     va_end(args);
 }
 
--- anacron-2.3/lock.c.memoryleak	2000-06-22 23:13:32.000000000 +0200
+++ anacron-2.3/lock.c	2006-10-10 15:40:37.000000000 +0200
@@ -42,7 +42,7 @@
     jr->timestamp_fd = open(jr->ident, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
     if (jr->timestamp_fd == -1)
 	die_e("Can't open timestamp file for job %s", jr->ident);
-    fcntl(jr->timestamp_fd, F_SETFD, 1);    /* set close-on-exec flag */
+    fcntl(jr->timestamp_fd, F_SETFD, FD_CLOEXEC);  /* set close-on-exec flag */
     /* We want to own this file, and set its mode to 0600. This is necessary
      * in order to prevent other users from putting locks on it. */
     if (fchown(jr->timestamp_fd, getuid(), getgid()))
--- anacron-2.3/matchrx.c.memoryleak	2000-06-21 01:12:18.000000000 +0200
+++ anacron-2.3/matchrx.c	2006-10-10 15:40:37.000000000 +0200
@@ -26,6 +26,7 @@
 #include <regex.h>
 #include <stdarg.h>
 #include <stdlib.h>
+#include <string.h>
 #include "matchrx.h"
 
 int
@@ -49,11 +50,23 @@
 	sub_offsets = malloc(sizeof(regmatch_t) * (n_sub + 1));
 	memset(sub_offsets, 0, sizeof(regmatch_t) * (n_sub + 1));
 
-	if (regcomp(&crx, rx, REG_EXTENDED)) return - 1;
+	if (regcomp(&crx, rx, REG_EXTENDED))
+	{
+		free(sub_offsets);
+		return - 1;
+	}
 	r = regexec(&crx, string, n_sub + 1, sub_offsets, 0);
-	if (r != 0 && r != REG_NOMATCH) return - 1;
+	if (r != 0 && r != REG_NOMATCH)
+	{
+		free(sub_offsets);
+		return - 1;
+	}
 	regfree(&crx);
-	if (r == REG_NOMATCH) return 0;
+	if (r == REG_NOMATCH)
+	{
+		free(sub_offsets);
+		return 0;
+	}
 
 	va_start(va, n_sub);
 	n = 1;
@@ -62,7 +75,11 @@
 		substring = va_arg(va, char**);
 		if (substring != NULL)
 		{
-			if (sub_offsets[n].rm_so == -1) return - 1;
+			if (sub_offsets[n].rm_so == -1)
+			{
+				free(sub_offsets);
+				return - 1;
+			}
 			*substring = string + sub_offsets[n].rm_so;
 			*(string + sub_offsets[n].rm_eo) = 0;
 		}

anacron-2.3-pie.patch:
 Makefile |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)

--- NEW FILE anacron-2.3-pie.patch ---
--- anacron-2.3/Makefile.pie	2006-10-10 13:21:57.000000000 +0200
+++ anacron-2.3/Makefile	2006-10-10 13:31:59.000000000 +0200
@@ -22,7 +22,8 @@
 PREFIX = 
 BINDIR = $(PREFIX)/usr/sbin
 MANDIR = $(PREFIX)/usr/man
-CFLAGS = -Wall -pedantic -O2
+LDFLAGS = -pie -Wl,-z,relro
+CFLAGS = -Wall -pedantic -W -Wundef -O2 -fpie
 #CFLAGS = -Wall -O2 -g -DDEBUG
 
 # If you change these, please update the man-pages too


Index: anacron.spec
===================================================================
RCS file: /cvs/dist/rpms/anacron/devel/anacron.spec,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- anacron.spec	29 Sep 2006 12:22:51 -0000	1.25
+++ anacron.spec	10 Oct 2006 13:58:59 -0000	1.26
@@ -1,7 +1,7 @@
 Summary: A cron-like program that can run jobs lost during downtime.
 Name: anacron
 Version: 2.3
-Release: 41%{?dist}
+Release: 43%{?dist}
 License: GPL
 Group: System Environment/Base
 Source: ftp://ftp.debian.org/debian/pool/main/a/anacron/%{name}_%{version}.orig.tar.gz
@@ -13,6 +13,9 @@
 Patch3: anacron-2.3-mailto.patch
 Patch4: anacron-2.3-lock-files.patch
 Patch5: anacron-2.3-fdclose.patch
+Patch6: anacron-2.3-hostname.patch
+Patch7: anacron-2.3-pie.patch
+Patch8: anacron-2.3-memoryleak.patch
 Requires: /bin/sh
 Requires: crontabs
 Prereq: /sbin/chkconfig
@@ -41,6 +44,9 @@
 %patch3 -p1 -b .mailto
 %patch4 -p1 -b .lock-files
 %patch5 -p1 -b .fdclose
+%patch6 -p1 -b .hostname
+%patch7 -p1 -b .pie
+%patch8 -p1 -b .memoryleak
 
 %build
 make CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags}
@@ -117,6 +123,13 @@
 %config /etc/cron.weekly/0anacron
 
 %changelog
+* Tue Oct 10 2006 Marcela Maslanova <mmaslano at redhat.com> 2.3-43
+- fix memory leaking (both #210020)
+- PIE executable
+
+* Tue Oct 2 2006 Marcela Maslanova <mmaslano at redhat.com> 2.3-42
+- hostname added to mail (#208914)
+
 * Fri Sep 29 2006 Marcela Maslanova <mmaslano at redhat.com> 2.3-41
 - change spec file - patch from Orion Poplawski (#191410)
 




More information about the fedora-cvs-commits mailing list