rpms/xorg-x11-server/F-11 xserver-1.6.1-avoid-malloc-for-logging.patch, NONE, 1.1 xorg-x11-server.spec, 1.440, 1.441

Adam Jackson ajax at fedoraproject.org
Thu Apr 23 18:39:49 UTC 2009


Author: ajax

Update of /cvs/pkgs/rpms/xorg-x11-server/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv4946

Modified Files:
	xorg-x11-server.spec 
Added Files:
	xserver-1.6.1-avoid-malloc-for-logging.patch 
Log Message:
* Thu Apr 23 2009 Adam Jackson <ajax at redhat.com> 1.6.1-9
- xserver-1.6.1-avoid-malloc-for-logging.patch: Don't malloc when logging,
  since that makes it unsafe to do from a signal handler.


xserver-1.6.1-avoid-malloc-for-logging.patch:

--- NEW FILE xserver-1.6.1-avoid-malloc-for-logging.patch ---
>From 0e0642ee9466d3268476d0084a83a9d93a4aa555 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer at who-t.net>
Date: Thu, 16 Apr 2009 16:17:07 +1000
Subject: [PATCH] os: don't malloc memory in LogVMessageVerb.

LogVWrite is limited to a buffer size of 1024, so we don't loose anything here
by truncating. This way we can use LogVMessageVerb (and xf86Msg and friends)
during signal handlers with the normal message types.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
Acked-by: Alan Coopersmith <alan.coopersmith at sun.com>
---
 os/log.c |   22 ++++++----------------
 1 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/os/log.c b/os/log.c
index 3961b0b..8108890 100644
--- a/os/log.c
+++ b/os/log.c
@@ -316,7 +316,7 @@ void
 LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
 {
     const char *s  = X_UNKNOWN_STRING;
-    char *tmpBuf = NULL;
+    char tmpBuf[1024];
 
     /* Ignore verbosity for X_ERROR */
     if (logVerbosity >= verb || logFileVerbosity >= verb || type == X_ERROR) {
@@ -358,21 +358,11 @@ LogVMessageVerb(MessageType type, int verb, const char *format, va_list args)
 	    break;
 	}
 
-	/*
-	 * Prefix the format string with the message type.  We do it this way
-	 * so that LogVWrite() is only called once per message.
-	 */
-	if (s) {
-	    tmpBuf = malloc(strlen(format) + strlen(s) + 1 + 1);
-	    /* Silently return if malloc fails here. */
-	    if (!tmpBuf)
-		return;
-	    sprintf(tmpBuf, "%s ", s);
-	    strcat(tmpBuf, format);
-	    LogVWrite(verb, tmpBuf, args);
-	    free(tmpBuf);
-	} else
-	    LogVWrite(verb, format, args);
+        /* if s is not NULL we need a space before format */
+        snprintf(tmpBuf, sizeof(tmpBuf), "%s%s%s", s ? s : "",
+                                                   s ? " " : "",
+                                                   format);
+        LogVWrite(verb, tmpBuf, args);
     }
 }
 
-- 
1.6.2.2



Index: xorg-x11-server.spec
===================================================================
RCS file: /cvs/pkgs/rpms/xorg-x11-server/F-11/xorg-x11-server.spec,v
retrieving revision 1.440
retrieving revision 1.441
diff -u -r1.440 -r1.441
--- xorg-x11-server.spec	23 Apr 2009 02:10:23 -0000	1.440
+++ xorg-x11-server.spec	23 Apr 2009 18:39:19 -0000	1.441
@@ -19,7 +19,7 @@
 Summary:   X.Org X11 X server
 Name:      xorg-x11-server
 Version:   1.6.1
-Release:   8%{?dist}
+Release:   9%{?dist}
 URL:       http://www.x.org
 License:   MIT
 Group:     User Interface/X
@@ -110,6 +110,7 @@
 # Nominated for 1.6.2
 Patch6033: xserver-1.6.1-activate-device.patch
 Patch6034: xserver-1.6.1-exa-create-pixmap2.patch
+Patch6035: xserver-1.6.1-avoid-malloc-for-logging.patch
 
 %define moduledir	%{_libdir}/xorg/modules
 %define drimoduledir	%{_libdir}/dri
@@ -543,6 +544,10 @@
 
 
 %changelog
+* Thu Apr 23 2009 Adam Jackson <ajax at redhat.com> 1.6.1-9
+- xserver-1.6.1-avoid-malloc-for-logging.patch: Don't malloc when logging,
+  since that makes it unsafe to do from a signal handler.
+
 * Thu Apr 23 2009 Dave Airlie <airlied at redhat.com> 1.6.1-8
 - xserver-1.6.1-exa-create-pixmap2.patch - add support for tiling create
   pixmap hook - need to fix firefox on ati rs690 crashes




More information about the fedora-extras-commits mailing list