- makedumpfile-fix-sprintf-append.patch: Fix string append in

dump_log_entry() (bnc#865596).
- makedumpfile-kernel-3.12-supported.patch: Mark kernel 3.12 as
  supported.

OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/makedumpfile?expand=0&rev=78
This commit is contained in:
Petr Tesařík
2014-02-25 16:03:52 +00:00
committed by Git OBS Bridge
parent c0cc13a092
commit 656887b1dd
4 changed files with 96 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
From: Petr Tesarik <ptesarik@suse.cz>
Subject: Fix string append in dump_log_entry()
References: bnc#865596
Patch-mainline: not yet
To quote the sprintf(3) man page:
Some programs imprudently rely on code such as the following
sprintf(buf, "%s some further text", buf);
to append text to buf. However, the standards explicitly note that
the results are undefined if source and destination buffers overlap
when calling sprintf(), snprintf(), vsprintf(), and vsnprintf().
Depending on the version of gcc(1) used, and the compiler options
employed, calls such as the above will not produce the expected results.
It's also overkill to call sprintf() for something that can be done
with a simple assignment.
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
makedumpfile.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -3830,7 +3830,7 @@ reset_bitmap_of_free_pages(unsigned long
static int
dump_log_entry(char *logptr, int fp)
{
- char *msg, *p;
+ char *msg, *p, *bufp;
unsigned int i, text_len;
unsigned long long ts_nsec;
char buf[BUFSIZE];
@@ -3845,20 +3845,21 @@ dump_log_entry(char *logptr, int fp)
msg = logptr + SIZE(printk_log);
- sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
+ bufp = buf;
+ bufp += sprintf(buf, "[%5lld.%06ld] ", nanos, rem/1000);
for (i = 0, p = msg; i < text_len; i++, p++) {
if (*p == '\n')
- sprintf(buf, "%s.", buf);
+ *bufp++ = '.';
else if (isprint(*p) || isspace(*p))
- sprintf(buf, "%s%c", buf, *p);
+ *bufp++ = *p;
else
- sprintf(buf, "%s.", buf);
+ *bufp++ = '.';
}
- sprintf(buf, "%s\n", buf);
+ *bufp++ = '\n';
- if (write(info->fd_dumpfile, buf, strlen(buf)) < 0)
+ if (write(info->fd_dumpfile, buf, bufp - buf) < 0)
return FALSE;
else
return TRUE;

View File

@@ -0,0 +1,20 @@
From: Petr Tesarik <ptesarik@suse.cz>
Subject: Mark kernel 3.12 as supported
Patch-mainline: not yet
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
---
makedumpfile.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -434,7 +434,7 @@ do { \
#define KVER_MIN_SHIFT 16
#define KERNEL_VERSION(x,y,z) (((x) << KVER_MAJ_SHIFT) | ((y) << KVER_MIN_SHIFT) | (z))
#define OLDEST_VERSION KERNEL_VERSION(2, 6, 15)/* linux-2.6.15 */
-#define LATEST_VERSION KERNEL_VERSION(3, 11, 3)/* linux-3.11.3 */
+#define LATEST_VERSION KERNEL_VERSION(3, 12, 0xffff)/* linux-3.12.x */
/*
* vmcoreinfo in /proc/vmcore

View File

@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue Feb 25 11:53:37 UTC 2014 - ptesarik@suse.cz
- makedumpfile-fix-sprintf-append.patch: Fix string append in
dump_log_entry() (bnc#865596).
- makedumpfile-kernel-3.12-supported.patch: Mark kernel 3.12 as
supported.
-------------------------------------------------------------------
Mon Feb 17 17:29:07 UTC 2014 - ptesarik@suse.cz

View File

@@ -37,6 +37,8 @@ Url: https://sourceforge.net/projects/makedumpfile/
Source: %{name}-%{version}.tar.bz2
Source1: README.static
Patch0: %{name}-coptflags.diff
Patch1: %{name}-fix-sprintf-append.patch
Patch2: %{name}-kernel-3.12-supported.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
ExclusiveArch: %ix86 x86_64 ia64 ppc ppc64 ppc64le s390x %arm
@@ -55,6 +57,8 @@ Authors:
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build
LIBS_STATIC=