File: CVE-2015-4644.patch.org

package info (click to toggle)
php5 5.3.3.1-7%2Bsqueeze29
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 123,520 kB
  • ctags: 55,742
  • sloc: ansic: 633,963; php: 19,620; sh: 11,344; xml: 5,816; cpp: 2,400; yacc: 1,745; exp: 1,514; makefile: 1,019; pascal: 623; awk: 537; sql: 22
file content (76 lines) | stat: -rw-r--r-- 2,166 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
From 2cc4e69cc6d8dbc4b3568ad3dd583324a7c11d64 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@php.net>
Date: Wed, 20 May 2015 08:08:41 +0200
Subject: [PATCH] Fixed Bug #69667 segfault in php_pgsql_meta_data

Incomplete fix for #68741
---
 ext/pgsql/pg_insert_002.phpt | 27 +++++++++++++++++++++++++++
 ext/pgsql/pgsql.c            |  9 +++++++--
 2 files changed, 34 insertions(+), 2 deletions(-)
 create mode 100644 ext/pgsql/pg_insert_002.phpt

diff --git a/ext/pgsql/pg_insert_002.phpt b/ext/pgsql/pg_insert_002.phpt
new file mode 100644
index 0000000..1393f5f
--- /dev/null
+++ b/ext/pgsql/pg_insert_002.phpt
@@ -0,0 +1,27 @@
+--TEST--
+PostgreSQL pg_select() - basic test using schema
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+include('config.inc');
+
+$conn = pg_connect($conn_str);
+
+foreach (array('', '.', '..') as $table) {
+	var_dump(pg_insert($conn, '',  array('id' => 1, 'id2' => 1)));
+}
+?>
+Done
+--EXPECTF--
+
+Warning: pg_insert(): The table name must be specified in %s on line %d
+bool(false)
+
+Warning: pg_insert(): The table name must be specified in %s on line %d
+bool(false)
+
+Warning: pg_insert(): The table name must be specified in %s on line %d
+bool(false)
+Done
\ No newline at end of file
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 23d55cb..5418b3c 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -5120,7 +5120,11 @@ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, z
 
 	src = estrdup(table_name);
 	tmp_name = php_strtok_r(src, ".", &tmp_name2);
-	
+	if (!tmp_name) {
+		efree(src);
+		php_error_docref(NULL TSRMLS_CC, E_WARNING, "The table name must be specified");
+		return FAILURE;
+	}
 	if (!tmp_name2 || !*tmp_name2) {
 		/* Default schema */
 		tmp_name2 = tmp_name;
@@ -6130,7 +6134,8 @@ static int do_exec(smart_str *querystr, int expect, PGconn *pg_link, ulong opt T
 
 static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const char *table)
 {
-	char *table_copy, *escaped, *token, *tmp;
+	char *table_copy, *escaped, *tmp;
+	const char *token;
 	size_t len;
 
 	/* schame.table should be "schame"."table" */
-- 
2.1.4