header.c: bug corrected
address.c mime.c misc.c: Always cast to (unsigned char) when using the ctype functions like isspace(); mbx_default.c: If _PATH_SENDMAIL not set via paths.h use "/usr/spool/mail" message.c: uidl is now <md5 . time . sequene> tcp.c: INADDR_NONE is not define on solaris define it to -1.
Showing
10 changed files
with
34 additions
and
23 deletions
... | @@ -44,7 +44,7 @@ struct token | ... | @@ -44,7 +44,7 @@ struct token |
44 | char word[1]; | 44 | char word[1]; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | #define SKIPSPACE(p) do { while(*p && isspace(*p)) p++; } while(0) | 47 | #define SKIPSPACE(p) do { while(*p && isspace((unsigned char)*p)) p++; } while(0) |
48 | 48 | ||
49 | /* Skip everything between quotes. */ | 49 | /* Skip everything between quotes. */ |
50 | static void | 50 | static void | ... | ... |
... | @@ -112,6 +112,7 @@ body_get_stream (body_t body, stream_t *pstream) | ... | @@ -112,6 +112,7 @@ body_get_stream (body_t body, stream_t *pstream) |
112 | if (fd == -1) | 112 | if (fd == -1) |
113 | return errno; | 113 | return errno; |
114 | status = stream_open (stream, body->filename, 0, MU_STREAM_RDWR); | 114 | status = stream_open (stream, body->filename, 0, MU_STREAM_RDWR); |
115 | close (fd); | ||
115 | if (status != 0) | 116 | if (status != 0) |
116 | return status; | 117 | return status; |
117 | body->stream = stream; | 118 | body->stream = stream; | ... | ... |
... | @@ -140,7 +140,7 @@ _file_write (stream_t stream, const char *iptr, size_t isize, | ... | @@ -140,7 +140,7 @@ _file_write (stream_t stream, const char *iptr, size_t isize, |
140 | err = errno; | 140 | err = errno; |
141 | } | 141 | } |
142 | else | 142 | else |
143 | fs->offset += *nbytes; | 143 | fs->offset += n; |
144 | 144 | ||
145 | if (nbytes) | 145 | if (nbytes) |
146 | *nbytes = n; | 146 | *nbytes = n; | ... | ... |
... | @@ -523,18 +523,13 @@ header_set_fill (header_t header, int | ... | @@ -523,18 +523,13 @@ header_set_fill (header_t header, int |
523 | static int | 523 | static int |
524 | fill_blurb (header_t header) | 524 | fill_blurb (header_t header) |
525 | { | 525 | { |
526 | stream_t is = NULL; | ||
527 | int status; | 526 | int status; |
528 | char buf[1024]; | 527 | char buf[1024]; |
529 | char *tbuf; | 528 | char *tbuf; |
530 | size_t nread = 0; | 529 | size_t nread = 0; |
531 | 530 | ||
532 | if (header->_fill == NULL) | 531 | if (header->_fill == NULL && header->stream == NULL) |
533 | { | 532 | return 0; |
534 | status = header_get_stream (header, &is); | ||
535 | if (status != 0) | ||
536 | return status; | ||
537 | } | ||
538 | 533 | ||
539 | do | 534 | do |
540 | { | 535 | { |
... | @@ -542,7 +537,7 @@ fill_blurb (header_t header) | ... | @@ -542,7 +537,7 @@ fill_blurb (header_t header) |
542 | status = header->_fill (header, buf, sizeof (buf), | 537 | status = header->_fill (header, buf, sizeof (buf), |
543 | header->temp_blurb_len, &nread) ; | 538 | header->temp_blurb_len, &nread) ; |
544 | else | 539 | else |
545 | status = stream_read (is, buf, sizeof (buf), | 540 | status = stream_read (header->stream, buf, sizeof (buf), |
546 | header->temp_blurb_len, &nread); | 541 | header->temp_blurb_len, &nread); |
547 | if (status != 0) | 542 | if (status != 0) |
548 | { | 543 | { |
... | @@ -610,7 +605,7 @@ header_read (stream_t is, char *buf, size_t buflen, off_t off, size_t *pnread) | ... | @@ -610,7 +605,7 @@ header_read (stream_t is, char *buf, size_t buflen, off_t off, size_t *pnread) |
610 | return EINVAL; | 605 | return EINVAL; |
611 | 606 | ||
612 | /* Try to fill out the buffer, if we know how. */ | 607 | /* Try to fill out the buffer, if we know how. */ |
613 | if (header->blurb == NULL) | 608 | if (header->blurb == NULL && header->_fill) |
614 | { | 609 | { |
615 | int err = fill_blurb (header); | 610 | int err = fill_blurb (header); |
616 | if (err != 0) | 611 | if (err != 0) |
... | @@ -651,7 +646,7 @@ header_readline (stream_t is, char *buf, size_t buflen, off_t off, size_t *pn) | ... | @@ -651,7 +646,7 @@ header_readline (stream_t is, char *buf, size_t buflen, off_t off, size_t *pn) |
651 | } | 646 | } |
652 | 647 | ||
653 | /* Try to fill out the buffer, if we know how. */ | 648 | /* Try to fill out the buffer, if we know how. */ |
654 | if (header->blurb == NULL) | 649 | if (header->blurb == NULL && header->_fill) |
655 | { | 650 | { |
656 | int err = fill_blurb (header); | 651 | int err = fill_blurb (header); |
657 | if (err != 0) | 652 | if (err != 0) | ... | ... |
... | @@ -142,7 +142,7 @@ locker_lock (locker_t lock, int flags) | ... | @@ -142,7 +142,7 @@ locker_lock (locker_t lock, int flags) |
142 | O_WRONLY | O_CREAT | O_EXCL, LOCKFILE_ATTR)) == -1) | 142 | O_WRONLY | O_CREAT | O_EXCL, LOCKFILE_ATTR)) == -1) |
143 | return errno; | 143 | return errno; |
144 | /* Success. */ | 144 | /* Success. */ |
145 | sprintf(buf, "%d", getpid()); | 145 | sprintf(buf, "%ld", (long)getpid()); |
146 | write(fd, buf, strlen(buf)); | 146 | write(fd, buf, strlen(buf)); |
147 | 147 | ||
148 | /* Try to get a file lock. */ | 148 | /* Try to get a file lock. */ | ... | ... |
1 | /* GNU mailutils - a suite of utilities for electronic mail | 1 | /* GNU mailutils - a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000 Free Software Foundation, Inc. | 2 | Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. |
3 | 3 | ||
4 | This program is free software; you can redistribute it and/or modify | 4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Library Public License as published by | 5 | it under the terms of the GNU General Library Public License as published by |
... | @@ -31,7 +31,7 @@ | ... | @@ -31,7 +31,7 @@ |
31 | #include <mailutils/mailbox.h> | 31 | #include <mailutils/mailbox.h> |
32 | 32 | ||
33 | #ifndef _PATH_MAILDIR | 33 | #ifndef _PATH_MAILDIR |
34 | # define _PATH_MAILDIR "/var/spool/mail" | 34 | # define _PATH_MAILDIR "/usr/spool/mail" |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | int | 37 | int | ... | ... |
... | @@ -437,14 +437,18 @@ message_get_uid (message_t msg, char *buffer, size_t buflen, size_t *pwriten) | ... | @@ -437,14 +437,18 @@ message_get_uid (message_t msg, char *buffer, size_t buflen, size_t *pwriten) |
437 | status = header_get_value (header, "X-UIDL", buffer, buflen, &n); | 437 | status = header_get_value (header, "X-UIDL", buffer, buflen, &n); |
438 | if (status == 0 && n > 0) | 438 | if (status == 0 && n > 0) |
439 | { | 439 | { |
440 | /* FIXME: Is header_get_value suppose to do this ? */ | 440 | /* FIXME: Is this necessary ? I did not see so far a x-uidl message |
441 | that broken i.e. | ||
442 | X-UIDL: <abaceekeke\n | ||
443 | jakdkjaja> | ||
444 | */ | ||
441 | /* We need to collapse the header if it was mutiline. e points to the | 445 | /* We need to collapse the header if it was mutiline. e points to the |
442 | last char meaning in a C string that's '\0', s to the start. We also | 446 | last char meaning in a C string that's '\0', s to the start. We also |
443 | remove the spesky '<' '>' if they are around. */ | 447 | remove the spesky '<' '>' if they are around. */ |
444 | char *s, *e; | 448 | char *s, *e; |
445 | for (s = buffer, e = buffer + n; s <= e; s++) | 449 | for (s = buffer, e = buffer + n; s <= e; s++) |
446 | { | 450 | { |
447 | if (isspace (*s) || *s == '<' || *s == '>') | 451 | if (isspace ((unsigned char)*s) || *s == '<' || *s == '>') |
448 | { | 452 | { |
449 | memmove (s, s + 1, e - (s + 1)); | 453 | memmove (s, s + 1, e - (s + 1)); |
450 | e -= 1; | 454 | e -= 1; |
... | @@ -454,6 +458,7 @@ message_get_uid (message_t msg, char *buffer, size_t buflen, size_t *pwriten) | ... | @@ -454,6 +458,7 @@ message_get_uid (message_t msg, char *buffer, size_t buflen, size_t *pwriten) |
454 | } | 458 | } |
455 | else | 459 | else |
456 | { | 460 | { |
461 | static unsigned long seq; | ||
457 | struct md5_ctx md5context; | 462 | struct md5_ctx md5context; |
458 | stream_t stream = NULL; | 463 | stream_t stream = NULL; |
459 | char buf[1024]; | 464 | char buf[1024]; |
... | @@ -474,6 +479,11 @@ message_get_uid (message_t msg, char *buffer, size_t buflen, size_t *pwriten) | ... | @@ -474,6 +479,11 @@ message_get_uid (message_t msg, char *buffer, size_t buflen, size_t *pwriten) |
474 | for (n = 0; n < 16; n++, tmp += 2) | 479 | for (n = 0; n < 16; n++, tmp += 2) |
475 | sprintf (tmp, "%02x", md5digest[n]); | 480 | sprintf (tmp, "%02x", md5digest[n]); |
476 | *tmp = '\0'; | 481 | *tmp = '\0'; |
482 | /* Access to sequence is not thread-safe, but that is not a problem. */ | ||
483 | seq++; | ||
484 | /* POP3 rfc says that an UID should not be longer than 70. */ | ||
485 | snprintf (buf + 32, 70, ".%lu.%lu", (unsigned long)time (NULL), seq); | ||
486 | |||
477 | header_set_value (header, "X-UIDL", buf, 1); | 487 | header_set_value (header, "X-UIDL", buf, 1); |
478 | buflen--; /* leave space for the NULL. */ | 488 | buflen--; /* leave space for the NULL. */ |
479 | strncpy (buffer, buf, buflen)[buflen] = '\0'; | 489 | strncpy (buffer, buf, buflen)[buflen] = '\0'; | ... | ... |
... | @@ -106,7 +106,7 @@ _strltrim(char *str) | ... | @@ -106,7 +106,7 @@ _strltrim(char *str) |
106 | { | 106 | { |
107 | char *p; | 107 | char *p; |
108 | 108 | ||
109 | for (p = str; isspace(*p) && *p != '\0'; ++p) | 109 | for (p = str; isspace((unsigned char)*p) && *p != '\0'; ++p) |
110 | ; | 110 | ; |
111 | return((p != str) ? memmove(str, p, strlen(p)+1) : str); | 111 | return((p != str) ? memmove(str, p, strlen(p)+1) : str); |
112 | } | 112 | } |
... | @@ -116,7 +116,7 @@ _strttrim(char *str) | ... | @@ -116,7 +116,7 @@ _strttrim(char *str) |
116 | { | 116 | { |
117 | char *p; | 117 | char *p; |
118 | 118 | ||
119 | for (p = str + strlen(str) - 1; isspace(*p) && p >= str; --p) | 119 | for (p = str + strlen(str) - 1; isspace((unsigned char)*p) && p >= str; --p) |
120 | ; | 120 | ; |
121 | *++p = '\0'; | 121 | *++p = '\0'; |
122 | return(str); | 122 | return(str); |
... | @@ -144,7 +144,7 @@ _mime_munge_content_header(char *field_body ) | ... | @@ -144,7 +144,7 @@ _mime_munge_content_header(char *field_body ) |
144 | while( *e == ';' ) { | 144 | while( *e == ';' ) { |
145 | p = e; | 145 | p = e; |
146 | e++; | 146 | e++; |
147 | while ( *e && isspace(*e) ) /* remove space upto param */ | 147 | while ( *e && isspace((unsigned char)*e) ) /* remove space upto param */ |
148 | e++; | 148 | e++; |
149 | memmove(p+1, e, strlen(e)+1); | 149 | memmove(p+1, e, strlen(e)+1); |
150 | e = p+1; | 150 | e = p+1; |
... | @@ -152,7 +152,7 @@ _mime_munge_content_header(char *field_body ) | ... | @@ -152,7 +152,7 @@ _mime_munge_content_header(char *field_body ) |
152 | while ( *e && *e != '=' ) /* find end of value */ | 152 | while ( *e && *e != '=' ) /* find end of value */ |
153 | e++; | 153 | e++; |
154 | e = p = e+1; | 154 | e = p = e+1; |
155 | while ( *e && (quoted || ( !_ISSPECIAL(*e) && !isspace(*e) ) ) ) { | 155 | while ( *e && (quoted || ( !_ISSPECIAL(*e) && !isspace((unsigned char)*e) ) ) ) { |
156 | if ( *e == '\\' ) { /* escaped */ | 156 | if ( *e == '\\' ) { /* escaped */ |
157 | memmove(e, e+1, strlen(e)+2); | 157 | memmove(e, e+1, strlen(e)+2); |
158 | } else if ( *e == '\"' ) | 158 | } else if ( *e == '\"' ) |
... | @@ -178,7 +178,7 @@ _mime_get_param(char *field_body, const char *param, int *len) | ... | @@ -178,7 +178,7 @@ _mime_get_param(char *field_body, const char *param, int *len) |
178 | break; | 178 | break; |
179 | *len = 0; | 179 | *len = 0; |
180 | v = e = v + 1; | 180 | v = e = v + 1; |
181 | while ( *e && (quoted || ( !_ISSPECIAL(*e) && !isspace(*e) ) ) ) { /* skip pass value and calc len */ | 181 | while ( *e && (quoted || ( !_ISSPECIAL(*e) && !isspace((unsigned char)*e) ) ) ) { /* skip pass value and calc len */ |
182 | if ( *e == '\"' ) | 182 | if ( *e == '\"' ) |
183 | quoted = ~quoted, was_quoted = 1; | 183 | quoted = ~quoted, was_quoted = 1; |
184 | else | 184 | else | ... | ... |
... | @@ -55,7 +55,7 @@ struct token | ... | @@ -55,7 +55,7 @@ struct token |
55 | char word[1]; | 55 | char word[1]; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | #define SKIPSPACE(p) do { while(*p && isspace(*p)) p++; } while(0) | 58 | #define SKIPSPACE(p) do { while(*p && isspace((unsigned char)*p)) p++; } while(0) |
59 | 59 | ||
60 | /* Skip everything between quotes. */ | 60 | /* Skip everything between quotes. */ |
61 | static void | 61 | static void | ... | ... |
... | @@ -34,6 +34,11 @@ | ... | @@ -34,6 +34,11 @@ |
34 | #include <mailutils/stream.h> | 34 | #include <mailutils/stream.h> |
35 | #include <tcp0.h> | 35 | #include <tcp0.h> |
36 | 36 | ||
37 | /* On solaris inet_addr() return -1. */ | ||
38 | #ifndef INADDR_NONE | ||
39 | # define INADDR_NONE (unsigned long)-1 | ||
40 | #endif | ||
41 | |||
37 | static int _tcp_close(stream_t stream) | 42 | static int _tcp_close(stream_t stream) |
38 | { | 43 | { |
39 | struct _tcp_instance *tcp = stream_get_owner(stream); | 44 | struct _tcp_instance *tcp = stream_get_owner(stream); | ... | ... |
-
Please register or sign in to post a comment