php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #70565
Patch fix_pdo_dblib.patch revision 2015-09-23 20:00 UTC by reyad dot attiyat at gmail dot com

Patch fix_pdo_dblib.patch for PDO DBlib Bug #70565

Patch version 2015-09-23 20:00 UTC

Return to Bug #70565 | Download this patch
Patch Revisions:

Developer: reyad.attiyat@gmail.com

From 29cc4e3a38543b51dd90aaec92be4457fa4a774e Mon Sep 17 00:00:00 2001
From: Reyad Attiyat <reyad.attiyat@gmail.com>
Date: Wed, 23 Sep 2015 14:53:16 -0500
Subject: [PATCH] Use safe_emalloc() instead of emalloc() to allocate quoted
 strings

---
 ext/pdo_dblib/dblib_driver.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c
index b3014a9..fec1f52 100644
--- a/ext/pdo_dblib/dblib_driver.c
+++ b/ext/pdo_dblib/dblib_driver.c
@@ -180,8 +180,7 @@ static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unqu
 		}
 	} else {
 		/* Alpha/Numeric Quoting */
-		*quotedlen += 2; /* +2 for opening, closing quotes */
-		q  = *quoted = emalloc(*quotedlen);
+		q  = *quoted = safe_emalloc(2, unquotedlen, 3);
 		*q++ = '\'';
 
 		for (i=0;i<unquotedlen;i++) {
@@ -197,6 +196,8 @@ static int dblib_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, size_t unqu
 
 	*q = 0;
 
+    *quotedlen = strlen(*quoted);
+
 	return 1;
 }
 
-- 
2.5.0

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 07:01:29 2024 UTC