apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From minf...@apache.org
Subject svn commit: r798703 - in /apr/apr-util/branches/1.3.x: CHANGES dbd/apr_dbd_mysql.c
Date Tue, 28 Jul 2009 20:42:55 GMT
Author: minfrin
Date: Tue Jul 28 20:42:55 2009
New Revision: 798703

URL: http://svn.apache.org/viewvc?rev=798703&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-util/branches/1.3.x/CHANGES
    apr/apr-util/branches/1.3.x/dbd/apr_dbd_mysql.c

Modified: apr/apr-util/branches/1.3.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/CHANGES?rev=798703&r1=798702&r2=798703&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/CHANGES [utf-8] (original)
+++ apr/apr-util/branches/1.3.x/CHANGES [utf-8] Tue Jul 28 20:42:55 2009
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes with APR-util 1.3.9
 
+  *) 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.
      Ensure the dbm module is packaged up correctly in the RPM.

Modified: apr/apr-util/branches/1.3.x/dbd/apr_dbd_mysql.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/dbd/apr_dbd_mysql.c?rev=798703&r1=798702&r2=798703&view=diff
==============================================================================
--- apr/apr-util/branches/1.3.x/dbd/apr_dbd_mysql.c (original)
+++ apr/apr-util/branches/1.3.x/dbd/apr_dbd_mysql.c Tue Jul 28 20:42:55 2009
@@ -112,6 +112,7 @@
                                          apr_off_t offset,
                                          apr_size_t len, apr_pool_t *p,
                                          apr_bucket_alloc_t *list);
+static int dbd_mysql_num_cols(apr_dbd_results_t *res);
 
 static const apr_bucket_type_t apr_bucket_type_lob = {
     "LOB", 5, APR_BUCKET_DATA,
@@ -256,7 +257,7 @@
     } else {
         ret = mysql_errno(sql->conn);
     }
-    
+
     if (TXN_NOTICE_ERRORS(sql->trans)) {
         sql->trans->errnum = ret;
     }
@@ -333,6 +334,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 +363,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 +1107,7 @@
 #endif
     MYSQL *real_conn;
     unsigned long flags = 0;
-    
+
     struct {
         const char *field;
         const char *value;
@@ -1176,7 +1183,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 +1263,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