Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit13a52c1

Browse files
committed
I installed postgres 7.1 with --enable-odbc. I then installed
tclodbc (http://sourceforge.net/projects/tclodbc) and libiodbc-2.50.3(http://www.iodbc.org/dist/libiodbc-2.50.3.tar.gz). I could notget either to work... postgres would not find the global odbcinst.inifile. I traced this to src/interfaces/odbc/gpps.c -- here are themany things I think are wrong:Run tclodbc and do a ``database db <DSNname>'' where ``DSNname'' isone of the DSN's in /usr/local/etc/odbcinst.ini (or wherever theglobal ini file is installed.) The result is always the errormessage that ``one of server,port,database,etc. are missing''.Run libiodbc-2.50.3/samples/odbctest <DSNname>. The command failsto connect to the database and just exits.Dave Bodenstab
1 parent55abc36 commit13a52c1

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

‎src/interfaces/odbc/gpps.c

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include<string.h>
3838
#include"misc.h"
3939
#include"gpps.h"
40+
#include"dlg_specific.h"
4041

4142
#ifndefTRUE
4243
#defineTRUE((BOOL)1)
@@ -46,6 +47,12 @@
4647
#endif
4748

4849

50+
/*
51+
* theIniFileName is searched for in:
52+
* $HOME/theIniFileName
53+
* theIniFileName
54+
* ODBCINST_INI
55+
*/
4956
DWORD
5057
GetPrivateProfileString(char*theSection,/* section name */
5158
char*theKey,/* search key name */
@@ -70,46 +77,38 @@ GetPrivateProfileString(char *theSection,/* section name */
7077
size_taReturnLength=0;
7178
BOOLaSectionFound= FALSE;
7279
BOOLaKeyFound= FALSE;
73-
intj=0;
80+
size_taReturnLength=0;
81+
BOOLaSectionFound= FALSE;
82+
BOOLaKeyFound= FALSE;
7483

75-
j=strlen(theIniFileName)+1;
7684
ptr= (char*)getpwuid(getuid());/* get user info */
7785

78-
if (ptr==NULL)
79-
{
80-
if (MAXPGPATH-1<j)
81-
theIniFileName[MAXPGPATH-1]='\0';
82-
83-
sprintf(buf,"%s",theIniFileName);
84-
}
85-
ptr= ((structpasswd*)ptr)->pw_dir;/* get user home dir */
86-
if (ptr==NULL||*ptr=='\0')
86+
if (ptr==NULL|| (((structpasswd*)ptr)->pw_dir)==NULL||*(((structpasswd*)ptr)->pw_dir)=='\0')
8787
ptr="/home";
88+
else
89+
ptr= ((structpasswd*)ptr)->pw_dir;/* get user home dir */
8890

8991
/*
90-
* This doesn't make it so we find an ini file but allows normal
91-
* processing to continue further on down. The likelihood is that the
92-
* file won't be found and thus the default value will be returned.
92+
* If it can't be opened because the paths are too long, then
93+
* skip it, don't just truncate the path string... The truncated path
94+
* might accidently be an existing file. The default value will be
95+
* returned instead.
9396
*/
94-
if (MAXPGPATH-1<strlen(ptr)+j)
97+
if (MAXPGPATH-1>=strlen(ptr)+1+strlen(theIniFileName))
9598
{
96-
if (MAXPGPATH-1<strlen(ptr))
97-
ptr[MAXPGPATH-1]='\0';
98-
else
99-
theIniFileName[MAXPGPATH-1-strlen(ptr)]='\0';
99+
sprintf(buf,"%s/%s",ptr,theIniFileName);
100+
aFile= (FILE*)fopen(buf,PG_BINARY_R);
100101
}
101102

102-
sprintf(buf,"%s/%s",ptr,theIniFileName);
103-
104103
/*
105104
* This code makes it so that a file in the users home dir overrides a
106105
* the "default" file as passed in
107106
*/
108-
aFile= (FILE*) (buf ?fopen(buf,PG_BINARY_R) :NULL);
109107
if (!aFile)
110108
{
111-
sprintf(buf,"%s",theIniFileName);
112-
aFile= (FILE*) (buf ?fopen(buf,PG_BINARY_R) :NULL);
109+
aFile= (FILE*)fopen(theIniFileName,PG_BINARY_R);
110+
if (!aFile)
111+
aFile= (FILE*)fopen(ODBCINST_INI,PG_BINARY_R);
113112
}
114113

115114
aLength= (theDefault==NULL) ?0 :strlen(theDefault);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp