Re: core dump using Pro*C on CONNECT

From: thumor <member34030_at_dbforums.com>
Date: Mon, 28 Jul 2003 15:44:12 +0000
Message-ID: <3157118.1059407052_at_dbforums.com>


Originally posted by Jonathan Leffler
> Frank Diedrich wrote:
>
> > "thumor" schrieb im Newsbeitrag
> > news:3148847.1059070191_at_dbforums.com"]news:3148847.105907-
> 0191_at_dbforums.com[/url]...
> >
> >>Line of code in my Pro*C file:
> >> strcpy(Username, user_id);
> >> strcpy(Userpass, user_pw);
> >> strcpy(DBname, db_name);
>
> Copy the string in user_id up to and including the terminal NUL '\0'
> into the variable Username. Repeat for the other two lines. No error
> checking on length; let's hope no-one was being malicious.
>
> >> strcat(Username, '\0');
> >> strcat(Userpass, '\0');
> >> strcat(DBname, '\0');
>
> Given the comment above, the attempt to append an extra NUL is
> pointless.
>
> Worse, strcat() takes a char pointer (const char *, or pointer to
> constant character data) as the second argument. Writing '\0' for the
> null pointer is obscure, but valid. OTOH, it also leads to
> core dumps.
>
> I recommend a visit to comp.lang.c or thereabouts.
>
> >>EXEC SQL CONNECT :Username IDENTIFIED BY :Userpass AT
> DB_NAME
> >>USING :DBname;
> >> if (sqlca.sqlcode != 0)
> >> {
> >> sprintf(Log_Msg, "Error %d (%s) Connecting
> Database
> >> ",sqlca.sqlcode,sqlca.sqlerrm);
> >> Log_Message(Waste_Log, "pods_init", FATAL,
> Log_Msg);
> >> }
> >> else
> >> {
> >> sprintf(Log_Msg, "Connection to Database
> Successful");
> >> Log_Message(Waste_Log, "pods_init", INFORM,
> Log_Msg);
> >> };
> >>I am running on HP-UX 10.2, ORACLE = 8.0.5
> >>I get core dumped on me after the CONNECT statement.
>
>
> After? Are you sure? How d'y'know?
>
> I'd expect it to be beforehand, as indicated...
>
> I do have a Log_Message() before the CONNECT which works.
> It is the Log_Message() after that never comes by.
>
> >>What seems to be the problem?
> >>Please help.
> >>--
> >>Posted via
> http://dbforums.com/http://dbforums.com
> >
> >
> > Hello,
> >
> > i had the same problems in coding with C. Try to use char in C
> and then
> > use the variable type declaration to declare the variable as
> string.
> > With this method, you don't need to get the length of the
> char-array all
> > the time (like with VARCHAR). See documentation for correct
> use.
> >
> > Greetings,
> >
> > Frank
> >
> >
> >
> >
>
>
> --
> Jonathan Leffler #include
> Email: jleffler_at_earthlink.net, jleffler_at_us.ibm.com
> Guardian of DBD::Informix v2003.04 --
> http://dbi.perl.org/http://dbi.perl.org/
>

All this worry about string manipulations does not seem to be the problem.
But where is the problem for CONNECT????

--
Posted via http://dbforums.com
Received on Mon Jul 28 2003 - 17:44:12 CEST

Original text of this message