Обсуждение: [patch] CodeGuard fix
Greetings,
the following patch (against 7.03.0200) contains two things:
    - The first hunk is necessary to build psqlodbc using Borland C++
Builder 6.0 [I successfully built the whole DLL, which requires a few
other patches]
    - The second hunk is necessary as Borland's sscanf would do all sorts
of things with rest[] when CodeGuard is active (I wonder if it's not
their way of hinting that we have an opportunity for a buffer overrun here).
I wonder if we shouldn't apply a better fix, to avoid entirely the "%s"
format argument to sscanf, and finding another way to locate a "const
char* rest" within the caller-supplied str?
Best Regards,
    -- Cyrille
			
		Cyrille Chépélov wrote:
> the following patch (against 7.03.0200) contains two things:
Note to self: ensure proper blood caffeine content before sending messages.
    -- Cyrille
--- psqlodbc-07.03.0200.vanilla/convert.c    2003-10-20 04:37:42.000000000 +0200
+++ psqlodbc-07.03.0200/convert.c    2003-12-17 10:24:12.000000000 +0100
@@ -44,9 +44,15 @@
 #endif
 #ifdef    __CYGWIN__
-#define TIMEZONE_GLOBAL _timezone
+#  define TIMEZONE_GLOBAL _timezone
 #elif    defined(WIN32) || defined(HAVE_INT_TIMEZONE)
-#define TIMEZONE_GLOBAL timezone
+#  ifdef __BORLANDC__
+#    define timezone _timzone
+#    define daylight _daylight
+#    define TIMEZONE_GLOBAL _timezone
+#  else
+#    define TIMEZONE_GLOBAL timezone
+#  endif
 #endif
 /*
@@ -195,6 +201,7 @@
     *zone = 0;
     st->fr = 0;
     st->infinity = 0;
+        rest[0] = 0;
     if ((scnt = sscanf(str, "%4d-%2d-%2d %2d:%2d:%2d%s", &st->y, &st->m, &st->d, &st->hh, &st->mm, &st->ss, rest)) <
6)
         return FALSE;
     else if (scnt == 6)
			
		> -----Original Message----- > From: Cyrille Ch���~ov > > Cyrille Chépélov wrote: > > > the following patch (against 7.03.0200) contains two things: > > Note to self: ensure proper blood caffeine content before > sending messages. In your patch . . +# ifdef __BORLANDC__ +# define timezone _timzone +# define daylight _daylight What are the above 2 lines for ? regards, Hiroshi Inoue
Hiroshi Inoue wrote:
> +#  ifdef __BORLANDC__
> +#    define timezone _timzone
> +#    define daylight _daylight
>
> What are the above 2 lines for ?
Oh, to account for stupid spraying of underscores in Borland's libc.
I can give you a whole BC++ patch if you want -- in my experience with
these 10-30 minutes of effort, the resulting DLL works as fine as if
compiled with VC++.
Best Regards,
    -- Cyrille
			
		Thanks. Patch applied. --------------------------------------------------------------------------- Cyrille Ch�p�lov wrote: > Cyrille Ch?p?lov wrote: > > > the following patch (against 7.03.0200) contains two things: > > Note to self: ensure proper blood caffeine content before sending messages. > > -- Cyrille > > > > --- psqlodbc-07.03.0200.vanilla/convert.c 2003-10-20 04:37:42.000000000 +0200 > +++ psqlodbc-07.03.0200/convert.c 2003-12-17 10:24:12.000000000 +0100 > @@ -44,9 +44,15 @@ > #endif > > #ifdef __CYGWIN__ > -#define TIMEZONE_GLOBAL _timezone > +# define TIMEZONE_GLOBAL _timezone > #elif defined(WIN32) || defined(HAVE_INT_TIMEZONE) > -#define TIMEZONE_GLOBAL timezone > +# ifdef __BORLANDC__ > +# define timezone _timzone > +# define daylight _daylight > +# define TIMEZONE_GLOBAL _timezone > +# else > +# define TIMEZONE_GLOBAL timezone > +# endif > #endif > > /* > @@ -195,6 +201,7 @@ > *zone = 0; > st->fr = 0; > st->infinity = 0; > + rest[0] = 0; > if ((scnt = sscanf(str, "%4d-%2d-%2d %2d:%2d:%2d%s", &st->y, &st->m, &st->d, &st->hh, &st->mm, &st->ss, rest)) < 6) > return FALSE; > else if (scnt == 6) > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: don't forget to increase your free space map settings -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073