]> granicus.if.org Git - php/commitdiff
MFB
authorIlia Alshanetsky <iliaa@php.net>
Mon, 28 May 2007 23:43:24 +0000 (23:43 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 28 May 2007 23:43:24 +0000 (23:43 +0000)
ext/mysql/php_mysql.c
ext/pdo/pdo_dbh.c
ext/pdo/pdo_sql_parser.c
ext/pdo/pdo_sql_parser.re
ext/pdo_mysql/mysql_statement.c
ext/soap/php_http.c
ext/xmlrpc/libxmlrpc/xml_to_dandarpc.c
ext/xmlrpc/libxmlrpc/xml_to_soap.c
ext/xmlrpc/libxmlrpc/xml_to_xmlrpc.c

index 95aedc25e0a27798fd85482b6d6d754a4004af07..54287968df265e65988ed27317be8d6702727949 100644 (file)
@@ -542,7 +542,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                        client_flags ^= CLIENT_LOCAL_FILES;
                }
 
-               hashed_details_length = spprintf(&hashed_details, 0, "mysql_%s_%s_%s", SAFE_STRING(host_and_port), SAFE_STRING(user), SAFE_STRING(passwd));
+               hashed_details_length = spprintf(&hashed_details, 0, "mysql_%s_%s_%s_%d", SAFE_STRING(host_and_port), SAFE_STRING(user), SAFE_STRING(passwd), client_flags);
        }
 
        /* We cannot use mysql_port anymore in windows, need to use
index 4925ddde014706a767406ad373b035e3aa702489..d169a59f8e558ad0ac5fd2981ab7b07fa35c5518 100755 (executable)
@@ -830,7 +830,7 @@ static PHP_METHOD(PDO, setAttribute)
 
        PDO_CONSTRUCT_CHECK;
 
-       if (pdo_dbh_attribute_set(dbh, attr, value TSRMLS_CC)) {
+       if (pdo_dbh_attribute_set(dbh, attr, value TSRMLS_CC) != FAILURE) {
                RETURN_TRUE;
        }
        RETURN_FALSE;
index 4355a97e68f37b0a82fb7fa2e772b3067341ce51..5215efb435f7fe936811910140f1f4dd1a1f483f 100644 (file)
@@ -327,13 +327,25 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len,
        }
 
        if (params && bindno != zend_hash_num_elements(params) && stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
+               /* extra bit of validation for instances when same params are bound more then once */
+               if (query_type != PDO_PLACEHOLDER_POSITIONAL && bindno > zend_hash_num_elements(params)) {
+                       int ok = 1;
+                       for (plc = placeholders; plc; plc = plc->next) {
+                               if (zend_hash_find(params, plc->pos, plc->len, (void**) &param) == FAILURE) {
+                                       ok = 0;
+                                       break;
+                               }
+                       }
+                       if (ok) {
+                               goto safe;
+                       }
+               }
                pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "number of bound variables does not match number of tokens" TSRMLS_CC);
                ret = -1;
                goto clean_up;
        }
-
+safe:
        /* what are we going to do ? */
-       
        if (stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
                /* query generation */
 
index c5c8cbaaf44ed3a159bb62962632fd4f3cb13532..0a6903f61bdbbd34362a97cb0b26934670f5b74f 100644 (file)
@@ -154,13 +154,25 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len,
        }
 
        if (params && bindno != zend_hash_num_elements(params) && stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
+               /* extra bit of validation for instances when same params are bound more then once */
+               if (query_type != PDO_PLACEHOLDER_POSITIONAL && bindno > zend_hash_num_elements(params)) {
+                       int ok = 1;
+                       for (plc = placeholders; plc; plc = plc->next) {
+                               if (zend_hash_find(params, plc->pos, plc->len, (void**) &param) == FAILURE) {
+                                       ok = 0;
+                                       break;
+                               }
+                       }
+                       if (ok) {
+                               goto safe;
+                       }
+               }
                pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "number of bound variables does not match number of tokens" TSRMLS_CC);
                ret = -1;
                goto clean_up;
        }
-
+safe:
        /* what are we going to do ? */
-       
        if (stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) {
                /* query generation */
 
index 86159d95abf200bbbe2fb00fee92fc1f14481f21..f0ff04dc9261ec9ffbff5289d81db213fb99ee71 100755 (executable)
@@ -363,6 +363,7 @@ static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt,
 #endif
 
        if (!S->result) {
+               strcpy(stmt->error_code, "HY000");
                return 0;       
        }
        if ((S->current_data = mysql_fetch_row(S->result)) == NULL) {
index 68ed03bd39f430270c650904ee883048ca15d2b5..4c355696b6e33ef98651d36149caa9719852e2dd 100644 (file)
@@ -916,19 +916,20 @@ try_again:
                                efree(http_body);
                                efree(loc);
                                if (new_url->scheme == NULL && new_url->path != NULL) {
-                                       new_url->scheme = estrdup(phpurl->scheme);
-                                       new_url->host = estrdup(phpurl->host);
+                                       new_url->scheme = NULL;
+                                       new_url->host = phpurl->host ? estrdup(phpurl->host) : NULL;
                                        new_url->port = phpurl->port;
                                        if (new_url->path && new_url->path[0] != '/') {
-                                               char *t = phpurl->path?phpurl->path:"/";
+                                               char *t = phpurl->path;
                                                char *p = strrchr(t, '/');
-                                               char *s = emalloc((p - t) + strlen(new_url->path) + 2);
-
-                                               strncpy(s, t, (p - t) + 1);
-                                               s[(p - t) + 1] = 0;
-                                               strcat(s, new_url->path);
-                                               efree(new_url->path);
-                                               new_url->path = s;
+                                               if (p) {
+                                                       char *s = emalloc((p - t) + strlen(new_url->path) + 2);
+                                                       strncpy(s, t, (p - t) + 1);
+                                                       s[(p - t) + 1] = 0;
+                                                       strcat(s, new_url->path);
+                                                       efree(new_url->path);
+                                                       new_url->path = s;
+                                               }
                                        }
                                }
                                phpurl = new_url;
index b51d99172361f4f06cfa50007df69293794c91ad..753222c55d8a28d69ce8dada995ae9574a8bbf05 100644 (file)
@@ -104,7 +104,7 @@ XMLRPC_VALUE xml_element_to_DANDARPC_REQUEST_worker(XMLRPC_REQUEST request, XMLR
          }
          else if(!strcmp(type, ATTR_BASE64)) {
             struct buffer_st buf;
-            base64_decode(&buf, el->text.str, el->text.len);
+            base64_decode_xmlrpc(&buf, el->text.str, el->text.len);
             XMLRPC_SetValueBase64(xCurrent, buf.data, buf.offset);
             buffer_delete(&buf);
          }
@@ -227,7 +227,7 @@ xml_element* DANDARPC_to_xml_element_worker(XMLRPC_REQUEST request, XMLRPC_VALUE
             {
                struct buffer_st buf;
                pAttrType = ATTR_BASE64;
-               base64_encode(&buf, XMLRPC_GetValueBase64(node), XMLRPC_GetValueStringLen(node));
+               base64_encode_xmlrpc(&buf, XMLRPC_GetValueBase64(node), XMLRPC_GetValueStringLen(node));
                simplestring_addn(&elem_val->text, buf.data, buf.offset );
                buffer_delete(&buf);
             }
index a30b3c11f73442ff9f9e0ad067610482151d26c8..76dcc034d9990043c756bd424a6e288da935b3ab 100644 (file)
@@ -363,7 +363,7 @@ XMLRPC_VALUE xml_element_to_SOAP_REQUEST_worker(XMLRPC_REQUEST request,
                        }
                        else if (!strcmp(type, TOKEN_BASE64)) {
                                struct buffer_st buf;
-                               base64_decode(&buf, el->text.str, el->text.len);
+                               base64_decode_xmlrpc(&buf, el->text.str, el->text.len);
                                XMLRPC_SetValueBase64(xCurrent, buf.data, buf.offset);
                                buffer_delete(&buf);
                        }
@@ -529,7 +529,7 @@ xml_element* SOAP_to_xml_element_worker(XMLRPC_REQUEST request, XMLRPC_VALUE nod
                        {
                                struct buffer_st buf;
                                pAttrType = TOKEN_BASE64;
-                               base64_encode(&buf, XMLRPC_GetValueBase64(node), XMLRPC_GetValueStringLen(node));
+                               base64_encode_xmlrpc(&buf, XMLRPC_GetValueBase64(node), XMLRPC_GetValueStringLen(node));
                                simplestring_addn(&elem_val->text, buf.data, buf.offset );
                                buffer_delete(&buf);
                        }
index 2a1e77312bbce1b626f94b426ba3993114172e87..13976077be6d19ea95213b24d10fdf861abc35b9 100644 (file)
@@ -139,7 +139,7 @@ XMLRPC_VALUE xml_element_to_XMLRPC_REQUEST_worker(XMLRPC_REQUEST request, XMLRPC
                }
                else if (!strcmp(el->name, ELEM_BASE64)) {
          struct buffer_st buf;
-         base64_decode(&buf, el->text.str, el->text.len);
+         base64_decode_xmlrpc(&buf, el->text.str, el->text.len);
          XMLRPC_SetValueBase64(current_val, buf.data, buf.offset);
          buffer_delete(&buf);
                }
@@ -242,7 +242,7 @@ xml_element* XMLRPC_to_xml_element_worker(XMLRPC_VALUE current_vector, XMLRPC_VA
             {
                struct buffer_st buf;
                elem_val->name = strdup(ELEM_BASE64);
-               base64_encode(&buf, XMLRPC_GetValueBase64(node), XMLRPC_GetValueStringLen(node));
+               base64_encode_xmlrpc(&buf, XMLRPC_GetValueBase64(node), XMLRPC_GetValueStringLen(node));
                simplestring_addn(&elem_val->text, buf.data, buf.offset );
                buffer_delete(&buf);
             }