Hello!
On Fri, 21 May 1999, Vladimir Litovka wrote:
> переделал и добавил немного диагностики - посмотри diff к message.c в
> конце письма.
Sorry, ошибка закралась.
============================== Cut here ==========================
--- imap/message.c.orig Thu Oct 29 22:16:31 1998
+++ imap/message.c Fri May 21 03:40:13 1999
@@ -240,7 +240,7 @@
else {
sawcr = 0;
blankline = 0;
- if (inheader && *p >= 0x80) {
+ if (inheader && *p >= 0x80 && *p < 0xC0) {
if (reject8bit) {
/* We have been configured to reject all mail of this
form. */
@@ -271,22 +271,29 @@
if (!fgets(buf, sizeof(buf), to)) return IMAP_MESSAGE_NOBLANKLINE;
/* End of header section */
- if (sawnl && buf[0] == '\r') return 0;
+ if (sawnl && (buf[0] == '\r' || buf[0] == '\n')) return 0;
/* Check for valid header name */
- if (sawnl && buf[0] != ' ' && buf[0] != '\t') {
- if (buf[0] == ':') return IMAP_MESSAGE_BADHEADER;
- for (p = (unsigned char *)buf; *p != ':'; p++) {
- if (*p <= ' ') return IMAP_MESSAGE_BADHEADER;
- }
- }
+ if (sawnl && buf[0] != ' ' && buf[0] != '\t')
+
+ /* Special check for "From " first line */
+ if (strncmp(buf, "From ", 5) != 0) {
+ /* If not, then usual header? */
+ p = strchr(buf, ':');
+ if (!p || p == (unsigned char *)buf || p[1] != ' ') {
+ syslog(LOG_ERR, "Bad header: '%s'", buf);
+ return IMAP_MESSAGE_BADHEADER;
+ }
+ else
+ for (p--; p >= (unsigned char *)buf; p--)
+ /* Only A-Z, a-z and '-' allowed in message's headers */
+ if (*p != '-' && (*p < 'A' || *p > 'Z') && (*p < 'a' || *p > 'z')) {
+ syslog(LOG_ERR, "Bad header: '%s'", buf);
+ return IMAP_MESSAGE_BADHEADER;
+ }
+ }
- /* Used to be some 8bit checks here but those were moved above so that
- we could do something other than refuse the message.
- Unfortunately, we still need to look for the end of the string. */
- for(p = (unsigned char*) buf; *p; p++);
-
- sawnl = (p[-1] == '\n');
+ sawnl = (buf[strlen(buf)-1] == '\n');
}
}
=============================================================================
"inet-admins" Internet access mailing list. Maintained by East Connection ISP.
Mail "unsubscribe inet-admins" to Majordomo@info.east.ru if you want to quit.
Archive is accessible on http://info.east.ru/rus/inetadm.html