I've implemented a partial/temp fix for this problem I stipulated
earlier. In dbmsgbuf.c/db_init_msgfetch the first two messageblks are
fetched and stored in a char pointer (msgbuf_buf).
Messages are still getting inserted with erroneous null's but at least
now users can still retrieve those messages. Since this problem appears
to manifest itself in the first messageblk, and my fix only strips off
nulls at the end of the first two blocks, I don't think Jesse's remarks
have much direct bearing on the issue, other than indicate the real
problem we have to fix.
Anyway, dispite a garbage-in situation still exists, we no longer have
to suffer from garbage out now :-)
Ilja Booij wrote:
I'v put this on the TODO list.
Anyway, we should really squash this last bug and move on to 2.0!
Problem is that I'll be really hard pressed for time the coming weeks so
it will really be helpful if everybody joins in to fix these strange
characters appearing in emails and the empty mail bodies.
Ilja
On Wed, 2004-04-14 at 16:41, Jesse Norell wrote:
Hello,
I've not been following this thread terribly closely, but does dbmail
allow messages with null's to be inserted properly? rfc 2822 allows
nulls within the message body, so if there were some in the original
message, and dbmail-{s,l}mtp allowed those to be inserted properly,
the behavior described below would cause incomplete messages to be
returned. I think the Right Thing(tm) is to allow nulls to be contained
in the message and returned just as the original message was - but I
know that gets ugly in C. Definitely put it on the future todo list
if nothing else...
---- Original Message ----
From: Ilja Booij <dbmail-dev@dbmail.org>
To: DBMAIL Developers Mailinglist <dbmail-dev@dbmail.org>
Subject: Re: [Dbmail-dev] parser bug
Sent: Wed, 14 Apr 2004 14:39:36 +0200
On Wed, 2004-04-14 at 14:13, Paul J Stevens wrote:
<snip info page>
So, if the row contains nulls, or db_get_length return value bigger than the
actual string length, msgbuf_buf is filled with nulls, correct?
I guess you're right :)
So, we should take the length of the string with strlen(), which would
result in the length up to the first NUL character, and use only that
part, and not send the NUL characters themselves.
This seems like logical behaviour, even though at first it's only a
workaround for our current problem.
Ilja
_______________________________________________
Dbmail-dev mailing list
Dbmail-dev@dbmail.org
http://twister.fastxs.net/mailman/listinfo/dbmail-dev
-- End Original Message --
--
Jesse Norell
[EMAIL PROTECTED] is not my email address;
change "administrator" to my first name.
--
_______________________________________________
Dbmail-dev mailing list
Dbmail-dev@dbmail.org
http://twister.fastxs.net/mailman/listinfo/dbmail-dev
_______________________________________________
Dbmail-dev mailing list
Dbmail-dev@dbmail.org
http://twister.fastxs.net/mailman/listinfo/dbmail-dev
--
________________________________________________________________
Paul Stevens mailto:[EMAIL PROTECTED]
NET FACILITIES GROUP PGP: finger [EMAIL PROTECTED]
The Netherlands________________________________http://www.nfg.nl
diff -urNad /usr/src/dbmail2/dbmail-2.0/dbmsgbuf.c dbmail-2.0/dbmsgbuf.c
--- /usr/src/dbmail2/dbmail-2.0/dbmsgbuf.c 2004-04-22 13:34:09.000000000 +0200
+++ dbmail-2.0/dbmsgbuf.c 2004-04-22 13:35:19.000000000 +0200
@@ -49,6 +49,7 @@
static db_pos_t zeropos; /**< absolute position (block/offset) of
msgbuf_buf[0]*/
static unsigned nblocks = 0; /**< number of block */
+static const char * tmprow;
int db_init_msgfetch(u64_t msg_idnr)
{
@@ -97,9 +98,14 @@
_msgrow_idx = 0;
/* FIXME: this will explode is db_get_result returns NULL. */
- rowlength = db_get_length(_msgrow_idx, 0);
- strncpy(msgbuf_buf, db_get_result(_msgrow_idx, 0),
- (size_t) MSGBUF_WINDOWSIZE - 1);
+ tmprow = db_get_result(_msgrow_idx, 0);
+ rowlength = (u64_t)strlen(tmprow);
+
+ if (! strncpy(msgbuf_buf,tmprow, MSGBUF_WINDOWSIZE - 1)) {
+ db_free_result();
+ free(msgbuf_buf);
+ return -1;
+ }
zeropos.block = 0;
zeropos.pos = 0;
@@ -121,10 +127,11 @@
}
/* FIXME: this will explode is db_get_result returns NULL. */
- rowlength = db_get_length(_msgrow_idx, 0);
rowpos = 0;
- strncpy(&msgbuf_buf[msgbuf_buflen], db_get_result(_msgrow_idx, 0),
- MSGBUF_WINDOWSIZE - msgbuf_buflen - 1);
+ tmprow = db_get_result(_msgrow_idx, 0);
+ rowlength = (u64_t)strlen(tmprow);
+
+ strncpy(&msgbuf_buf[msgbuf_buflen], tmprow, MSGBUF_WINDOWSIZE - msgbuf_buflen - 1);
if (rowlength <= MSGBUF_WINDOWSIZE - msgbuf_buflen - 1) {
/* 2nd block fits entirely */