This repository has been archived on 2026-01-16. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
anacron/anacron-2.3-memleaking.patch
2006-12-04 10:33:33 +00:00

213 lines
6 KiB
Diff

diff -ur anacron-2.3.orig/global.h anacron-2.3/global.h
--- anacron-2.3.orig/global.h 2006-10-08 09:58:47.000000000 -0400
+++ anacron-2.3/global.h 2006-10-08 10:08:18.000000000 -0400
@@ -108,18 +108,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
@@ -130,8 +137,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);
diff -ur anacron-2.3.orig/gregor.c anacron-2.3/gregor.c
--- anacron-2.3.orig/gregor.c 2006-10-08 09:58:47.000000000 -0400
+++ anacron-2.3/gregor.c 2006-10-08 10:24:05.000000000 -0400
@@ -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) */
diff -ur anacron-2.3.orig/lock.c anacron-2.3/lock.c
--- anacron-2.3.orig/lock.c 2006-10-08 09:58:47.000000000 -0400
+++ anacron-2.3/lock.c 2006-10-08 16:14:14.000000000 -0400
@@ -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()))
diff -ur anacron-2.3.orig/log.c anacron-2.3/log.c
--- anacron-2.3.orig/log.c 2006-10-08 09:58:47.000000000 -0400
+++ anacron-2.3/log.c 2006-10-08 10:27:29.000000000 -0400
@@ -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);
}
diff -ur anacron-2.3.orig/matchrx.c anacron-2.3/matchrx.c
--- anacron-2.3.orig/matchrx.c 2006-10-08 09:58:47.000000000 -0400
+++ anacron-2.3/matchrx.c 2006-10-08 10:29:24.000000000 -0400
@@ -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;
}
diff -ur anacron-2.3.orig/runjob.c anacron-2.3/runjob.c
--- anacron-2.3.orig/runjob.c 2006-10-08 09:58:47.000000000 -0400
+++ anacron-2.3/runjob.c 2006-10-08 16:09:37.000000000 -0400
@@ -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;
@@ -178,7 +178,7 @@
pid = xfork();
if (pid == 0)
{
- long fdflags;
+ /* long fdflags; */
/* child */
in_background = 1;