Re: core dump using Pro*C on CONNECT
From: Pete Finnigan <pete_at_petefinnigan.com>
Date: Fri, 25 Jul 2003 10:23:05 +0100
Message-ID: <ZtheITB5bPI$EwU7_at_peterfinnigan.demon.co.uk>
Date: Fri, 25 Jul 2003 10:23:05 +0100
Message-ID: <ZtheITB5bPI$EwU7_at_peterfinnigan.demon.co.uk>
Hi
Compile with -g and then execute your program in gdb and when it crashes it will give you the line number where it fails in the Pro*C program, type "up" to see the stack frame, keep doing this until you come to the top of the stack if needed so you can see where your function / code is called from. This should tell you exactly which line is in error.
For your info this is code i have used recently and it works:
void ConnectToDatabase(LOL *l)
{
[Quoted] EXEC SQL BEGIN DECLARE SECTION; VARCHAR OmDbUserName[30]; VARCHAR OmDbPassword[30]; VARCHAR OmDbName[30]; VARCHAR OmUserId[2]; EXEC SQL END DECLARE SECTION; EXEC SQL DECLARE MY_DB DATABASE; /* connect user username and password */ COPY_STR_TO_VARCHAR(OmDbUserName,l->param->dbusername); COPY_STR_TO_VARCHAR(OmDbPassword,l->param->dbpassword); if(l->param->dbname) { COPY_STR_TO_VARCHAR(OmDbName,l->param->dbname); EXEC SQL CONNECT :OmDbUserName IDENTIFIED BY :OmDbPassword AT MY_DB USING :OmDbName; if(sqlca.sqlcode!=PORA_SUCCESS) { ErrorSQLFatal(l,&sqlca); } else
...
code removed here
...
the macro is defined as:
#define COPY_STR_TO_VARCHAR(dest,source) \
strncpy(dest.arr,source,strlen(source)); \ dest.len=strlen(source); \ dest.arr[dest.len]='\0';
PORA-SUCCESS is defined as 0
I think the difference between my code and your is my use of the EXEC
SQL DECLARE {DB NAME} DATABASE;
and my macro call's to copy the varchar.
hth
kind regards
Pete
-- Pete Finnigan email:pete_at_petefinnigan.com Web site: http://www.petefinnigan.com - Oracle security audit specialists Book:Oracle security step-by-step Guide - see http://store.sans.org for details.Received on Fri Jul 25 2003 - 11:23:05 CEST