Closed
Bug 152468
Opened 24 years ago
Closed 24 years ago
string truncation causes filter misses
Categories
(MailNews Core :: Filters, defect)
MailNews Core
Filters
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla1.1beta
People
(Reporter: dmosedale, Assigned: dmosedale)
References
Details
Attachments
(1 file)
|
2.23 KB,
patch
|
naving
:
review+
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
I was seeing some filter misses that I didn't expect in my spam filters, so I
started putting printfs in the code. The problem seems to happen at
nsMsgBodyHandler::GetNextLine around this line of code:
while (eatThisLine && length >= 0); // if we hit eof, make sure we break out of
this loop. Bug #:
return length;
What ends up happening is that sometimes -1 gets returned, and then the next
call to GetNextLine ends up down in GetNextFilterLine in this code:
else if (m_headersSize == 0) {
buf[0] = '\0';
}
Which causes the last byte of the previous header to be overwritten with null.
It's possible that just changing the while loop to look for length > 0 is the
correct fix; I'm not entirely sure.
Comment 2•24 years ago
|
||
dmose, can you elaborate what type of filters you have ? thx.
| Assignee | ||
Comment 3•24 years ago
|
||
These are filters that are filtering over IMAP against "custom header". Example
filter:
name="spam: content-type"
enabled="yes"
type="1"
action="Move to folder"
actionValue="imap://dmose@imap.meer.net/Potential Spam"
condition="AND (\"Content-Type\",contains,charset=) AND
(\"Content-Type\",doesn't contain,charset=us-ascii) AND
(\"Content-Type\",doesn't contain,charset=iso-8859-1) AND
(\"Content-Type\",doesn't contain,charset=\\"us-ascii\\") AND
(\"Content-Type\",doesn't contain,charset=\\"iso-8859-1\\")"
This filter often incorrectly matches one of the last two and conditions because
the final quote mark has been trounced by a null.
| Assignee | ||
Comment 4•24 years ago
|
||
My initial diagnosis was wrong. The real problem here is that
nsParseMailMessageState::FinalizeHeaders() is destructive, and writes NULLs into
the header in several places (notably Message-ID, Content-Type: charset= , and
Newsgroups) in order to cheaply truncate strings.
| Assignee | ||
Comment 5•24 years ago
|
||
I've got a patch... taking.
Assignee: naving → dmose
Summary: off-by-one error causes filter misses → string truncation causes filter misses
Target Milestone: --- → mozilla1.1beta
| Assignee | ||
Updated•24 years ago
|
Status: NEW → ASSIGNED
| Assignee | ||
Comment 6•24 years ago
|
||
Generate new truncated strings, rather than writing into ones that should be
read-only. This is the right fix, assuming nothing else depends on the old
behaviorial side-effects (which seems fairly unlikely).
Comment 7•24 years ago
|
||
So, in this instance, to be clear, you were counting on the trailing " in the
charset header to be there. This fix looks OK to me, but the other alternative
is to simply save and restore the crunched character(s) instead of copying the
string, which would be faster.
| Assignee | ||
Comment 8•24 years ago
|
||
bienvenu: yes on all counts. I considered doing the crunch/restore solution,
but it was clear that this data was already shared, and not being confident that
I understood all the sharing that was going on, I had threadsafety fears. I
also didn't like the fact that it forces us to violate |const char *|-typed
data. What would you prefer I do?
Comment 9•24 years ago
|
||
Comment on attachment 90360 [details] [diff] [review]
patch, v1
sr=bienvenu
Attachment #90360 -
Flags: superreview+
Comment 10•24 years ago
|
||
there aren't any threadsafety issues - this data is only manipulated on the ui
thread. However, I think the copying is OK. It's not going to slow us down
appreciably.
Comment 11•24 years ago
|
||
Comment on attachment 90360 [details] [diff] [review]
patch, v1
r=naving
Attachment #90360 -
Flags: review+
| Assignee | ||
Comment 12•24 years ago
|
||
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Updated•21 years ago
|
Product: MailNews → Core
Updated•18 years ago
|
Product: Core → MailNews Core
You need to log in
before you can comment on or make changes to this bug.
Description
•