Update of /cvsroot/monetdb/sql/src/backends/monet5/merovingian
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv31566

Modified Files:
      Tag: Feb2010
        merovingian_client.c 
Added Files:
      Tag: Feb2010
        ChangeLog.Feb2010 
Log Message:
Fix bug #2964247, thanks Sjoerd for debugging.

Index: merovingian_client.c
===================================================================
RCS file: 
/cvsroot/monetdb/sql/src/backends/monet5/merovingian/merovingian_client.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- merovingian_client.c        7 Jan 2010 15:24:31 -0000       1.2
+++ merovingian_client.c        5 Mar 2010 14:55:53 -0000       1.2.2.1
@@ -227,23 +227,22 @@
                                strerror(errno));
                host = "(unknown)";
        } else {
-               /* avoid doing this, it requires some includes that probably
-                * give trouble on windowz
-               host = inet_ntoa(saddr.sin_addr);
-                */
+               size_t len;
                struct hostent *hoste = 
                        gethostbyaddr(&saddr.sin_addr.s_addr, 4, 
saddr.sin_family);
                if (hoste == NULL) {
-                       host = alloca(sizeof(char) * ((3 + 1 + 3 + 1 + 3 + 1 + 
3) + 1));
-                       sprintf(host, "%u.%u.%u.%u:%u",
+                       len = (3 + 1 + 3 + 1 + 3 + 1 + 3 + 1 + 5) + 1;
+                       host = alloca(sizeof(char) * len);
+                       snprintf(host, len, "%u.%u.%u.%u:%u",
                                        (unsigned) 
((ntohl(saddr.sin_addr.s_addr) >> 24) & 0xff),
                                        (unsigned) 
((ntohl(saddr.sin_addr.s_addr) >> 16) & 0xff),
                                        (unsigned) 
((ntohl(saddr.sin_addr.s_addr) >> 8) & 0xff),
                                        (unsigned) 
(ntohl(saddr.sin_addr.s_addr) & 0xff),
                                        (unsigned) (ntohs(saddr.sin_port)));
                } else {
-                       host = alloca(sizeof(char) * (strlen(hoste->h_name) + 1 
+ 5 + 1));
-                       sprintf(host, "%s:%u",
+                       len = strlen(hoste->h_name) + 1 + 5 + 1;
+                       host = alloca(sizeof(char) * len);
+                       snprintf(host, len, "%s:%u",
                                        hoste->h_name, (unsigned) 
(ntohs(saddr.sin_port)));
                }
        }

--- NEW FILE: ChangeLog.Feb2010 ---
# ChangeLog file for sql/src/backends/monet5/merovingian
# This file is updated with mchangelog

  05 Mar 2010; Fabian Groffen <[email protected]> merovingian_client.c:
  Avoid running over the allocated buffer space resulting in crashes
  when a client connects which IP address cannot be resolved into a
  hostname, bug #2964247

*Feb2010

  21 Jan 2010; Fabian Groffen <[email protected]> monetdb.c:
  Changed wording of monetdb status -l for last crash to indicate the time
  reported is not the crash time, but the time the server was started which
  eventually crashed, bug #2900355

  13 Jan 2010; Fabian Groffen <[email protected]> merovingian.c:
  Strip trailing newlines from the control channel password, bug #2931392


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to