From: "Christian Stalp" <christian.stalp@gmx.de>
To: linux-c-programming@vger.kernel.org
Subject: Re: sprintf with mips
Date: Sun, 10 Feb 2008 23:25:59 +0100 [thread overview]
Message-ID: <20080210222559.17830@gmx.net> (raw)
The whole procedure is here: (its a thread!)
void *dblogger_fn (void *arg)
{
char insertvalues[256];
memset (insertvalues, 0x0, 256 );
conn = PQconnectdb("host=192.168.1.2 dbname=wlan_db user=gavle password=brynaes");
tabellename = "traffic";
if (PQstatus(conn) == CONNECTION_BAD)
{
fprintf(stderr, "Connection to database '%s' failed.\n",dbName);
fprintf(stderr, "%s", PQerrorMessage(conn));
exit_nicely(conn);
}
else if (PQstatus(conn) == CONNECTION_OK)
{
printf("Connected with database ...\n");
printf("Datenbank : %s\n", PQdb(conn));
printf("User : %s\n", PQuser(conn));
}
while(1)
{
sleep(500);
snprintf(insertvalues, 255 ," %d , ' %s ' , %d ", counter, "192.168.1.1", mytraffic->num_frames);
printf("input-string: %s\n", insertvalues);
printf("Counter: %d\n", counter);
insertinto(dbName, conn, tabellename, insertvalues);
counter++;
}
I don't know where is here a chance for an overflow? Consider, now with 'snprintf' it works, but before with sprintf there was this problem, BUT only on the mips-target board. On x86 it worked also with sprintf!
Gruss Christian
Paul Jackson wrote:
>> are there any known problems with sprintf under mips?
>
> Is there any chance that some other line of code, perhaps
> writing an adjacent variable, is overflowing onto the
> front of this insertvalues[] array, between the sprintf
> and the printf?
>
> In other words, I'll wager that whatever bug you're seeing
> is neither in the code fragements quoted here, nor in the
> sprintf libc code, but in some other nearby code.
>
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2008-02-10 22:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-10 22:25 Christian Stalp [this message]
2008-02-12 14:17 ` sprintf with mips Stephen Kratzer
2008-02-12 16:31 ` Paul Jackson
-- strict thread matches above, loose matches on Subject: below --
2008-02-06 22:48 Christian Stalp
2008-02-07 0:10 ` Paul Jackson
2008-02-06 20:14 Christian Stalp
2008-02-06 19:58 Christian Stalp
2008-02-06 19:16 Christian Stalp
2008-02-06 19:45 ` Manning, Gary L
2008-02-06 21:21 ` Eric Polino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080210222559.17830@gmx.net \
--to=christian.stalp@gmx.de \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.