Re: sprintf with mips

"Christian Stalp" <[email protected]>
Newsgroups org.kernel.vger.linux-c-programming
Message-ID <[email protected]>
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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.