Hello Steve,
After a few weeks of tests in the field, the attached, revised patch has
resulted in no further accidentally truncated odbc.ini files.
I have changed four places in the code where I found suspicious "w"
options to uo_fopen(). In these four places, I changed the "w" option to
"a".
The installation where we found the problems is Ubuntu 14.04, so the
patch was made to an older version. But it should also apply to the
current version.
Maybe this patch is acceptable and can find its way into Debian and by
extension into Ubuntu and other derivatives.
Cheers,
- Ján
--- unixodbc-2.2.14p2.orig/ini/iniCommit.c
+++ unixodbc-2.2.14p2/ini/iniCommit.c
@@ -30,7 +30,7 @@
if (hIni->iniFileType == 0)
{
#endif
- hFile = uo_fopen( hIni->szFileName, "w" );
+ hFile = uo_fopen( hIni->szFileName, "a" );
#ifdef __OS2__
}
else
--- unixodbc-2.2.14p2.orig/ini/iniOpen.c
+++ unixodbc-2.2.14p2/ini/iniOpen.c
@@ -234,7 +234,7 @@
if ( bCreate == TRUE )
{
if ( (*hIni)->iniFileType == 0 )
- hFile = uo_fopen( pszFileName, "w" );
+ hFile = uo_fopen( pszFileName, "a" );
else
hFile = (FILE *)iniOS2Open( pszFileName);
}
@@ -404,7 +404,7 @@
if ( bCreate == TRUE )
{
- hFile = uo_fopen( pszFileName, "w" );
+ hFile = uo_fopen( pszFileName, "a" );
}
}
--- unixodbc-2.2.14p2.orig/odbcinst/_odbcinst_SystemINI.c
+++ unixodbc-2.2.14p2/odbcinst/_odbcinst_SystemINI.c
@@ -176,7 +176,7 @@
else
{
/* does not exist so try creating it */
- hFile = uo_fopen( pszFileName, "w" );
+ hFile = uo_fopen( pszFileName, "a" );
if ( hFile )
uo_fclose( hFile );
else