Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9396/backends/monet5

Modified Files:
      Tag: Aug2009
        sql_readline.mx sql_scenario.mx 
Log Message:
Hardening: deal with failing realloc in buffer streams.

Index: sql_scenario.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_scenario.mx,v
retrieving revision 1.352.2.5
retrieving revision 1.352.2.6
diff -u -d -r1.352.2.5 -r1.352.2.6
--- sql_scenario.mx     21 Sep 2009 21:15:20 -0000      1.352.2.5
+++ sql_scenario.mx     30 Oct 2009 16:59:11 -0000      1.352.2.6
@@ -794,7 +794,10 @@
                        }
                        in->eof = 0;
                }
-               if (go && (rd = bstream_next(in)) <= 0) {
+               if (in->buf == NULL) {
+                       more = FALSE;
+                       go = FALSE;
+               } else if (go && (rd = bstream_next(in)) <= 0) {
 #ifdef _SQL_READER_DEBUG
                        stream_printf(GDKout, "#rd %d  language %d eof %d\n", 
rd, language, in->eof);
 #endif

Index: sql_readline.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_readline.mx,v
retrieving revision 1.13
retrieving revision 1.13.4.1
diff -u -d -r1.13 -r1.13.4.1
--- sql_readline.mx     17 May 2009 21:33:17 -0000      1.13
+++ sql_readline.mx     30 Oct 2009 16:59:11 -0000      1.13.4.1
@@ -181,7 +181,13 @@
                size_t len = strlen(buf);
                if( len >= cntxt->fdin->size) {
                        /* extremly dirty inplace buffer overwriting */
+                       assert(cntxt->fdin->buf);
                        cntxt->fdin->buf= realloc(cntxt->fdin->buf, len+1);
+                       if (cntxt->fdin->buf == NULL) {
+                               cntxt->fdin->len = 0;
+                               cntxt->fdin->size = 0;
+                               return -1;
+                       }
                        cntxt->fdin->len = len;
                        cntxt->fdin->size = len;
                } 


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to