iliaa                                    Sun, 07 Aug 2011 23:46:00 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=314450

Log:
Fixes for variety of issues identified by coverity scan

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/pdo/pdo.c
    U   php/php-src/branches/PHP_5_3/ext/pdo/pdo_dbh.c
    U   php/php-src/branches/PHP_5_3/ext/pdo/pdo_sql_parser.re
    U   php/php-src/branches/PHP_5_3/ext/pdo/php_pdo_int.h
    U   php/php-src/branches/PHP_5_4/ext/pdo/pdo.c
    U   php/php-src/branches/PHP_5_4/ext/pdo/pdo_dbh.c
    U   php/php-src/branches/PHP_5_4/ext/pdo/pdo_sql_parser.re
    U   php/php-src/trunk/ext/pdo/pdo.c
    U   php/php-src/trunk/ext/pdo/pdo_dbh.c
    U   php/php-src/trunk/ext/pdo/pdo_sql_parser.re

Modified: php/php-src/branches/PHP_5_3/ext/pdo/pdo.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo/pdo.c  2011-08-07 19:42:27 UTC (rev 
314449)
+++ php/php-src/branches/PHP_5_3/ext/pdo/pdo.c  2011-08-07 23:46:00 UTC (rev 
314450)
@@ -191,7 +191,7 @@
        }

        return zend_hash_add(&pdo_driver_hash, (char*)driver->driver_name, 
driver->driver_name_len,
-                       (void**)&driver, sizeof(driver), NULL);
+                       (void**)&driver, sizeof(pdo_driver_t *), NULL);
 }

 PDO_API void php_pdo_unregister_driver(pdo_driver_t *driver)

Modified: php/php-src/branches/PHP_5_3/ext/pdo/pdo_dbh.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo/pdo_dbh.c      2011-08-07 19:42:27 UTC 
(rev 314449)
+++ php/php-src/branches/PHP_5_3/ext/pdo/pdo_dbh.c      2011-08-07 23:46:00 UTC 
(rev 314450)
@@ -57,7 +57,7 @@
                pdo_err = &stmt->error_code;
        }

-       strcpy(*pdo_err, sqlstate);
+       strncpy(*pdo_err, sqlstate, 6);

        /* hash sqlstate to error messages */
        msg = pdo_sqlstate_state_to_description(*pdo_err);

Modified: php/php-src/branches/PHP_5_3/ext/pdo/pdo_sql_parser.re
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo/pdo_sql_parser.re      2011-08-07 
19:42:27 UTC (rev 314449)
+++ php/php-src/branches/PHP_5_3/ext/pdo/pdo_sql_parser.re      2011-08-07 
23:46:00 UTC (rev 314450)
@@ -236,6 +236,9 @@
                                                        plc->freeq = 0;
                                                        break;

+                                               case IS_BOOL:
+                                                       
convert_to_long(param->parameter);
+
                                                case IS_LONG:
                                                case IS_DOUBLE:
                                                        
convert_to_string(param->parameter);
@@ -244,8 +247,6 @@
                                                        plc->freeq = 0;
                                                        break;

-                                               case IS_BOOL:
-                                                       
convert_to_long(param->parameter);
                                                default:
                                                        
convert_to_string(param->parameter);
                                                        if 
(!stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),

Modified: php/php-src/branches/PHP_5_3/ext/pdo/php_pdo_int.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo/php_pdo_int.h  2011-08-07 19:42:27 UTC 
(rev 314449)
+++ php/php-src/branches/PHP_5_3/ext/pdo/php_pdo_int.h  2011-08-07 23:46:00 UTC 
(rev 314450)
@@ -58,7 +58,7 @@
 extern void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC);

 #define PDO_DBH_CLEAR_ERR()            do { \
-       strlcpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \
+       strncpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \
        if (dbh->query_stmt) { \
                dbh->query_stmt = NULL; \
                zend_objects_store_del_ref(&dbh->query_stmt_zval TSRMLS_CC); \

Modified: php/php-src/branches/PHP_5_4/ext/pdo/pdo.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/pdo/pdo.c  2011-08-07 19:42:27 UTC (rev 
314449)
+++ php/php-src/branches/PHP_5_4/ext/pdo/pdo.c  2011-08-07 23:46:00 UTC (rev 
314450)
@@ -191,7 +191,7 @@
        }

        return zend_hash_add(&pdo_driver_hash, (char*)driver->driver_name, 
driver->driver_name_len,
-                       (void**)&driver, sizeof(driver), NULL);
+                       (void**)&driver, sizeof(pdo_driver_t *), NULL);
 }

 PDO_API void php_pdo_unregister_driver(pdo_driver_t *driver)

Modified: php/php-src/branches/PHP_5_4/ext/pdo/pdo_dbh.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/pdo/pdo_dbh.c      2011-08-07 19:42:27 UTC 
(rev 314449)
+++ php/php-src/branches/PHP_5_4/ext/pdo/pdo_dbh.c      2011-08-07 23:46:00 UTC 
(rev 314450)
@@ -57,7 +57,7 @@
                pdo_err = &stmt->error_code;
        }

-       strcpy(*pdo_err, sqlstate);
+       strncpy(*pdo_err, sqlstate, 6);

        /* hash sqlstate to error messages */
        msg = pdo_sqlstate_state_to_description(*pdo_err);

Modified: php/php-src/branches/PHP_5_4/ext/pdo/pdo_sql_parser.re
===================================================================
--- php/php-src/branches/PHP_5_4/ext/pdo/pdo_sql_parser.re      2011-08-07 
19:42:27 UTC (rev 314449)
+++ php/php-src/branches/PHP_5_4/ext/pdo/pdo_sql_parser.re      2011-08-07 
23:46:00 UTC (rev 314450)
@@ -236,6 +236,9 @@
                                                        plc->freeq = 0;
                                                        break;

+                                               case IS_BOOL:
+                                                       
convert_to_long(param->parameter);
+
                                                case IS_LONG:
                                                case IS_DOUBLE:
                                                        
convert_to_string(param->parameter);
@@ -244,8 +247,6 @@
                                                        plc->freeq = 0;
                                                        break;

-                                               case IS_BOOL:
-                                                       
convert_to_long(param->parameter);
                                                default:
                                                        
convert_to_string(param->parameter);
                                                        if 
(!stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),

Modified: php/php-src/trunk/ext/pdo/pdo.c
===================================================================
--- php/php-src/trunk/ext/pdo/pdo.c     2011-08-07 19:42:27 UTC (rev 314449)
+++ php/php-src/trunk/ext/pdo/pdo.c     2011-08-07 23:46:00 UTC (rev 314450)
@@ -191,7 +191,7 @@
        }

        return zend_hash_add(&pdo_driver_hash, (char*)driver->driver_name, 
driver->driver_name_len,
-                       (void**)&driver, sizeof(driver), NULL);
+                       (void**)&driver, sizeof(pdo_driver_t *), NULL);
 }

 PDO_API void php_pdo_unregister_driver(pdo_driver_t *driver)

Modified: php/php-src/trunk/ext/pdo/pdo_dbh.c
===================================================================
--- php/php-src/trunk/ext/pdo/pdo_dbh.c 2011-08-07 19:42:27 UTC (rev 314449)
+++ php/php-src/trunk/ext/pdo/pdo_dbh.c 2011-08-07 23:46:00 UTC (rev 314450)
@@ -57,7 +57,7 @@
                pdo_err = &stmt->error_code;
        }

-       strcpy(*pdo_err, sqlstate);
+       strncpy(*pdo_err, sqlstate, 6);

        /* hash sqlstate to error messages */
        msg = pdo_sqlstate_state_to_description(*pdo_err);

Modified: php/php-src/trunk/ext/pdo/pdo_sql_parser.re
===================================================================
--- php/php-src/trunk/ext/pdo/pdo_sql_parser.re 2011-08-07 19:42:27 UTC (rev 
314449)
+++ php/php-src/trunk/ext/pdo/pdo_sql_parser.re 2011-08-07 23:46:00 UTC (rev 
314450)
@@ -236,6 +236,9 @@
                                                        plc->freeq = 0;
                                                        break;

+                                               case IS_BOOL:
+                                                       
convert_to_long(param->parameter);
+
                                                case IS_LONG:
                                                case IS_DOUBLE:
                                                        
convert_to_string(param->parameter);
@@ -244,8 +247,6 @@
                                                        plc->freeq = 0;
                                                        break;

-                                               case IS_BOOL:
-                                                       
convert_to_long(param->parameter);
                                                default:
                                                        
convert_to_string(param->parameter);
                                                        if 
(!stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter),

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to