apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r798678 - in /apr/apr/trunk: CHANGES dbd/apr_dbd_mysql.c
Date Tue, 28 Jul 2009 19:40:02 GMT
Author: minfrin
Date: Tue Jul 28 19:40:01 2009
New Revision: 798678

URL: http://svn.apache.org/viewvc?rev=798678&view=rev
Log:
Make sure the mysql version of dbd_mysql_get_entry() respects the
rule that if the column number exceeds the number of columns, we
return NULL.

Modified:
    apr/apr/trunk/CHANGES
    apr/apr/trunk/dbd/apr_dbd_mysql.c

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=798678&r1=798677&r2=798678&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Tue Jul 28 19:40:01 2009
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 2.0.0
 
+  *) Make sure the mysql version of dbd_mysql_get_entry() respects the
+     rule that if the column number exceeds the number of columns, we
+     return NULL. [Graham Leggett]
+
   *) Make sure the LD_LIBRARY_PATH is sensible when running the tests
      from the RPM build, so that the crypto, dbd and dbm tests pass.
      Transfer the apr-util spec file contents to apr.spec. [Graham

Modified: apr/apr/trunk/dbd/apr_dbd_mysql.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/dbd/apr_dbd_mysql.c?rev=798678&r1=798677&r2=798678&view=diff
==============================================================================
--- apr/apr/trunk/dbd/apr_dbd_mysql.c (original)
+++ apr/apr/trunk/dbd/apr_dbd_mysql.c Tue Jul 28 19:40:01 2009
@@ -256,7 +256,7 @@
     } else {
         ret = mysql_errno(sql->conn);
     }
-    
+
     if (TXN_NOTICE_ERRORS(sql->trans)) {
         sql->trans->errnum = ret;
     }
@@ -333,6 +333,9 @@
                                apr_dbd_datum_t *val)
 {
     MYSQL_BIND *bind;
+    if (dbd_mysql_num_cols(row->res) <= n) {
+    	return NULL;
+    }
     if (row->res->statement) {
         bind = &row->res->bind[n];
         if (mysql_stmt_fetch_column(row->res->statement, bind, n, 0) != 0) {
@@ -359,6 +362,9 @@
 static const char *dbd_mysql_get_entry(const apr_dbd_row_t *row, int n)
 {
     MYSQL_BIND *bind;
+    if (dbd_mysql_num_cols(row->res) <= n) {
+    	return NULL;
+    }
     if (row->res->statement) {
         bind = &row->res->bind[n];
         if (mysql_stmt_fetch_column(row->res->statement, bind, n, 0) != 0) {
@@ -1100,7 +1106,7 @@
 #endif
     MYSQL *real_conn;
     unsigned long flags = 0;
-    
+
     struct {
         const char *field;
         const char *value;
@@ -1176,7 +1182,7 @@
     /* the MySQL manual says this should be BEFORE mysql_real_connect */
     mysql_options(sql->conn, MYSQL_OPT_RECONNECT, &do_reconnect);
 #endif
-    
+
     real_conn = mysql_real_connect(sql->conn, fields[0].value,
                                    fields[1].value, fields[2].value,
                                    fields[3].value, port,
@@ -1256,8 +1262,8 @@
 {
     my_init();
     mysql_thread_init();
-   
-    /* FIXME: this is a guess; find out what it really does */ 
+
+    /* FIXME: this is a guess; find out what it really does */
     apr_pool_cleanup_register(pool, NULL, thread_end, apr_pool_cleanup_null);
 }
 APU_MODULE_DECLARE_DATA const apr_dbd_driver_t apr_dbd_mysql_driver = {



Mime
View raw message