summaryrefslogtreecommitdiff
path: root/dev-db/unixODBC/files/unixODBC-2.3.5-CVE-2018-7485.patch
blob: 2c4178cda48f7115189bc4189df12e8d3371bc3b (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
From 45ef78e037f578b15fc58938a3a3251655e71d6f Mon Sep 17 00:00:00 2001
From: Nick Gorham <nick@lurcher.ink.org>
Date: Mon, 8 Jan 2018 11:12:39 +0000
Subject: [PATCH] New Pre Source

diff --git a/DriverManager/SQLGetDiagRecW.c b/DriverManager/SQLGetDiagRecW.c
index a6368d7..be89120 100644
--- a/DriverManager/SQLGetDiagRecW.c
+++ b/DriverManager/SQLGetDiagRecW.c
@@ -98,6 +98,8 @@
 
 static char const rcsid[]= "$RCSfile: SQLGetDiagRecW.c,v $";
 
+extern int __is_env( EHEAD * head );        /* in SQLGetDiagRec.c */
+
 static SQLRETURN extract_sql_error_rec_w( EHEAD *head,
         SQLWCHAR *sqlstate,
         SQLINTEGER rec_number,
diff --git a/DriverManager/SQLSetDescField.c b/DriverManager/SQLSetDescField.c
index 333d786..0e2f67c 100644
--- a/DriverManager/SQLSetDescField.c
+++ b/DriverManager/SQLSetDescField.c
@@ -306,7 +306,7 @@ SQLRETURN SQLSetDescField( SQLHDESC descriptor_handle,
         return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
     }
 
-    if ( field_identifier == SQL_DESC_COUNT && (SQLINTEGER)value < 0 )
+    if ( field_identifier == SQL_DESC_COUNT && (intptr_t)value < 0 )
     {
         __post_internal_error( &descriptor -> error,
                 ERROR_07009, NULL,
@@ -315,9 +315,9 @@ SQLRETURN SQLSetDescField( SQLHDESC descriptor_handle,
         return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
     }
     
-    if ( field_identifier == SQL_DESC_PARAMETER_TYPE && value != SQL_PARAM_INPUT
-        && value != SQL_PARAM_OUTPUT && value != SQL_PARAM_INPUT_OUTPUT &&
-        value != SQL_PARAM_INPUT_OUTPUT_STREAM && value != SQL_PARAM_OUTPUT_STREAM )
+    if ( field_identifier == SQL_DESC_PARAMETER_TYPE && (intptr_t)value != SQL_PARAM_INPUT
+        && (intptr_t)value != SQL_PARAM_OUTPUT && (intptr_t)value != SQL_PARAM_INPUT_OUTPUT &&
+        (intptr_t)value != SQL_PARAM_INPUT_OUTPUT_STREAM && (intptr_t)value != SQL_PARAM_OUTPUT_STREAM )
     {
         __post_internal_error( &descriptor -> error,
                 ERROR_HY105, NULL,
diff --git a/DriverManager/SQLSetDescFieldW.c b/DriverManager/SQLSetDescFieldW.c
index 5e066ac..45125ff 100644
--- a/DriverManager/SQLSetDescFieldW.c
+++ b/DriverManager/SQLSetDescFieldW.c
@@ -288,7 +288,7 @@ SQLRETURN SQLSetDescFieldW( SQLHDESC descriptor_handle,
         return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
     }
 
-    if ( field_identifier == SQL_DESC_COUNT && (SQLINTEGER)value < 0 )
+    if ( field_identifier == SQL_DESC_COUNT && (intptr_t)value < 0 )
     {
         __post_internal_error( &descriptor -> error,
                 ERROR_07009, NULL,
@@ -297,9 +297,9 @@ SQLRETURN SQLSetDescFieldW( SQLHDESC descriptor_handle,
         return function_return_nodrv( SQL_HANDLE_DESC, descriptor, SQL_ERROR );
     }
 
-    if ( field_identifier == SQL_DESC_PARAMETER_TYPE && value != SQL_PARAM_INPUT
-        && value != SQL_PARAM_OUTPUT && value != SQL_PARAM_INPUT_OUTPUT &&
-        value != SQL_PARAM_INPUT_OUTPUT_STREAM && value != SQL_PARAM_OUTPUT_STREAM )
+    if ( field_identifier == SQL_DESC_PARAMETER_TYPE && (intptr_t)value != SQL_PARAM_INPUT
+        && (intptr_t)value != SQL_PARAM_OUTPUT && (intptr_t)value != SQL_PARAM_INPUT_OUTPUT &&
+        (intptr_t)value != SQL_PARAM_INPUT_OUTPUT_STREAM && (intptr_t)value != SQL_PARAM_OUTPUT_STREAM )
     {
         __post_internal_error( &descriptor -> error,
                 ERROR_HY105, NULL,
diff --git a/exe/iusql.c b/exe/iusql.c
index aac5329..484a889 100644
--- a/exe/iusql.c
+++ b/exe/iusql.c
@@ -413,7 +413,6 @@ static int ExecuteSQL( SQLHDBC hDbc, char *szSQL, char cDelimiter, int bColumnNa
             if ( bVerbose ) DumpODBCLog( hEnv, hDbc, hStmt );
             fprintf( stderr, "[ISQL]ERROR: Could not SQLExecDirect\n" );
             SQLFreeStmt( hStmt, SQL_DROP );
-            free(szSepLine);
             return 0;
         }
     }
diff --git a/odbcinst/SQLCreateDataSource.c b/odbcinst/SQLCreateDataSource.c
index a9fa735..83a1e9e 100644
--- a/odbcinst/SQLCreateDataSource.c
+++ b/odbcinst/SQLCreateDataSource.c
@@ -26,7 +26,7 @@ char* _multi_string_alloc_and_copy( LPCWSTR in )
 
     if ( !in )
     {
-        return in;
+        return NULL;
     }
 
     while ( in[ len ] != 0 || in[ len + 1 ] != 0 )
@@ -55,7 +55,7 @@ char* _single_string_alloc_and_copy( LPCWSTR in )
 
     if ( !in )
     {
-        return in;
+        return NULL;
     }
 
     while ( in[ len ] != 0 )
@@ -83,7 +83,7 @@ SQLWCHAR* _multi_string_alloc_and_expand( LPCSTR in )
 
     if ( !in )
     {
-        return in;
+        return NULL;
     }
     
     while ( in[ len ] != 0 || in[ len + 1 ] != 0 )
@@ -112,7 +112,7 @@ SQLWCHAR* _single_string_alloc_and_expand( LPCSTR in )
 
     if ( !in )
     {
-        return in;
+        return NULL;
     }
 
     while ( in[ len ] != 0 )
diff --git a/odbcinst/SQLWriteFileDSN.c b/odbcinst/SQLWriteFileDSN.c
index c2f987b..e225796 100644
--- a/odbcinst/SQLWriteFileDSN.c
+++ b/odbcinst/SQLWriteFileDSN.c
@@ -21,7 +21,7 @@ BOOL SQLWriteFileDSN(			LPCSTR	pszFileName,
 
 	if ( pszFileName[0] == '/' )
 	{
-		strncpy( szFileName, sizeof(szFileName) - 5, pszFileName );
+		strncpy( szFileName, pszFileName, sizeof(szFileName) - 5 );
 	}
 	else
 	{