[Patch] Some suggested patches

Roland Baer roland at verifysoft.de
Fri Aug 18 16:31:20 CEST 2006


Hello,

please find attached my cumulative patches
- rxvt-unicode.patch 

Notes for new stuff:
- rxvt_term::IM_get_IC(): found can be used uninitialised. 
           At least one data path leads to that, unproofed if that can ever 
           happen in practice, but as long as we have suspicious problems,
           fix that to be on safe side.

- rxvtd.C: Adjusted the sockname length check to the one in rxvtc.C. 
           Otherwise this would throw an (uncaught) exception.
- rxvtd.C: If chdir() fails, just print something, then continue.
- rxvtd.C: envv, argv get deleted now in one path, no leak
- rxvtd.C: delete[] colors instead of delete colors. More correct.

- xpm.C rxvt_term::scale_pixmap(): Made str[] 1 bigger, otherwise we
           would have an buffer overflow later " str[n] = '\0';"
           Proof that we can hit that:
            echo -e "\E]20;;100000x100000+100000+10000;?\a"

In summary, this fixes out 7 of 46 Coverity found possible problems.

Best regards,

	Roland Bär

-------------- next part --------------
Index: Makefile.in
===================================================================
RCS file: /schmorpforge/rxvt-unicode/src/Makefile.in,v
retrieving revision 1.74
diff -u -w -r1.74 Makefile.in
--- Makefile.in	7 Aug 2006 16:17:30 -0000	1.74
+++ Makefile.in	18 Aug 2006 14:12:43 -0000
@@ -137,7 +137,7 @@
 	$(PERL) -MExtUtils::Embed -e xsinit -- -std urxvt
 
 rxvtperl.C: rxvtperl.xs typemap
-	$(PERL) @PERLPRIVLIBEXP@/ExtUtils/xsubpp -C++ -typemap @PERLPRIVLIBEXP@/ExtUtils/typemap -typemap typemap -prototypes rxvtperl.xs >$@
+	$(PERL) @PERLPRIVLIBEXP@/ExtUtils/xsubpp -csuffix .C -C++ -typemap @PERLPRIVLIBEXP@/ExtUtils/typemap -typemap typemap -prototypes rxvtperl.xs >$@
 
 rxvtperl.o: rxvtperl.C perlxsi.c
 	$(COMPILE) @PERLFLAGS@ -DLIBDIR="\"$(libdir)/urxvt\"" -c $<
Index: main.C
===================================================================
RCS file: /schmorpforge/rxvt-unicode/src/main.C,v
retrieving revision 1.228
diff -u -w -r1.228 main.C
--- main.C	2 Aug 2006 09:14:19 -0000	1.228
+++ main.C	18 Aug 2006 14:12:45 -0000
@@ -1337,7 +1337,7 @@
 bool
 rxvt_term::IM_get_IC (const char *modifiers)
 {
-  int i, j, found;
+  int i, j, found = 0;
   XIM xim;
   XPoint spot;
   XRectangle rect, status_rect, needed_rect;
Index: rxvtd.C
===================================================================
RCS file: /schmorpforge/rxvt-unicode/src/rxvtd.C,v
retrieving revision 1.30
diff -u -w -r1.30 rxvtd.C
--- rxvtd.C	9 Aug 2006 22:01:07 -0000	1.30
+++ rxvtd.C	18 Aug 2006 14:12:46 -0000
@@ -74,7 +74,10 @@
   sockaddr_un sa;
   
   if (strlen(sockname) >= sizeof(sa.sun_path))
-    rxvt_fatal ("socket name too long, aborting.\n");
+    {
+      fputs ("socket name too long, aborting.\n", stderr);
+      exit (EXIT_FAILURE);
+    }
 
   if ((fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
     {
@@ -173,14 +176,16 @@
               else if (!strcmp (tok, "CWD") && recv (tok))
                 {
                   if (chdir (tok))
-                    err ("unable to change to working directory to '%s': %s",
-                         (char *)tok, strerror (errno));
+                    perror ("unable to change to current working directory of client");
                 }
               else if (!strcmp (tok, "ARG") && recv (tok))
                 argv->push_back (strdup (tok));
-              else
+              else {
+		delete envv;
+		delete argv;
                 return err ("protocol error: unexpected NEW token");
             }
+            }
 
           envv->push_back (0);
 
Index: rxvttoolkit.C
===================================================================
RCS file: /schmorpforge/rxvt-unicode/src/rxvttoolkit.C,v
retrieving revision 1.62
diff -u -w -r1.62 rxvttoolkit.C
--- rxvttoolkit.C	7 Aug 2006 15:41:05 -0000	1.62
+++ rxvttoolkit.C	18 Aug 2006 14:12:47 -0000
@@ -811,7 +811,7 @@
           
       got = alloc (screen, rgba (best->red, best->green, best->blue));
 
-      delete colors;
+      delete[] colors;
     }
 #endif
 
Index: xpm.C
===================================================================
RCS file: /schmorpforge/rxvt-unicode/src/xpm.C,v
retrieving revision 1.34
diff -u -w -r1.34 xpm.C
--- xpm.C	20 Feb 2006 22:42:01 -0000	1.34
+++ xpm.C	18 Aug 2006 14:12:48 -0000
@@ -65,7 +65,7 @@
   if (geom == NULL)
     return 0;
 
-  char str[MAXLEN_GEOM];
+  char str[MAXLEN_GEOM+1];
 
   if (!strcmp (geom, "?"))
     {


More information about the rxvt-unicode mailing list