Commit acb3a8e2 acb3a8e2a9d76611d9cf2b099d95eab10c5f2189 by Sergey Poznyakoff

Properly check the return from headers_aget_value.

1 parent f5b2407d
...@@ -568,7 +568,7 @@ fetch_envelope0 (message_t msg) ...@@ -568,7 +568,7 @@ fetch_envelope0 (message_t msg)
568 /* Note that the server MUST default the reply-to and sender fields from 568 /* Note that the server MUST default the reply-to and sender fields from
569 the From field; a client is not expected to know to do this. */ 569 the From field; a client is not expected to know to do this. */
570 header_aget_value (header, "Sender", &buffer); 570 header_aget_value (header, "Sender", &buffer);
571 fetch_send_address ((*buffer == '\0') ? from : buffer); 571 fetch_send_address (buffer ? buffer : from);
572 free (buffer); 572 free (buffer);
573 util_send (" "); 573 util_send (" ");
574 574
...@@ -576,7 +576,7 @@ fetch_envelope0 (message_t msg) ...@@ -576,7 +576,7 @@ fetch_envelope0 (message_t msg)
576 /* Note that the server MUST default the reply-to and sender fields from 576 /* Note that the server MUST default the reply-to and sender fields from
577 the From field; a client is not expected to know to do this. */ 577 the From field; a client is not expected to know to do this. */
578 header_aget_value (header, "Reply-to", &buffer); 578 header_aget_value (header, "Reply-to", &buffer);
579 fetch_send_address ((*buffer == '\0') ? from : buffer); 579 fetch_send_address (buffer ? buffer : from);
580 free (buffer); 580 free (buffer);
581 util_send (" "); 581 util_send (" ");
582 582
...@@ -664,7 +664,8 @@ fetch_bodystructure0 (message_t message, int extension) ...@@ -664,7 +664,8 @@ fetch_bodystructure0 (message_t message, int extension)
664 message_get_header (message, &header); 664 message_get_header (message, &header);
665 665
666 /* The subtype. */ 666 /* The subtype. */
667 header_aget_value (header, MU_HEADER_CONTENT_TYPE, &buffer); 667 if (header_aget_value (header, MU_HEADER_CONTENT_TYPE, &buffer) == 0)
668 {
668 s = strtok_r (buffer, " \t\r\n;", &sp); 669 s = strtok_r (buffer, " \t\r\n;", &sp);
669 if (s) 670 if (s)
670 { 671 {
...@@ -672,6 +673,7 @@ fetch_bodystructure0 (message_t message, int extension) ...@@ -672,6 +673,7 @@ fetch_bodystructure0 (message_t message, int extension)
672 if (s) 673 if (s)
673 *s++ = '\0'; 674 *s++ = '\0';
674 } 675 }
676 }
675 util_send (" "); 677 util_send (" ");
676 util_send_qstring (s); 678 util_send_qstring (s);
677 679
...@@ -787,9 +789,8 @@ bodystructure (message_t msg, int extension) ...@@ -787,9 +789,8 @@ bodystructure (message_t msg, int extension)
787 789
788 /* body type: Content-Type 790 /* body type: Content-Type
789 body subtype: */ 791 body subtype: */
790 header_aget_value (header, MU_HEADER_CONTENT_TYPE, &buffer); 792 if (header_aget_value (header, MU_HEADER_CONTENT_TYPE, &buffer) == 0
791 s = strtok_r (buffer, " \t\r\n;", &sp); 793 && (s = strtok_r (buffer, " \t\r\n;", &sp)) != NULL)
792 if (s)
793 { 794 {
794 char *p = strchr (s, '/'); 795 char *p = strchr (s, '/');
795 if (strcasecmp (s, "MESSAGE/RFC822") == 0) 796 if (strcasecmp (s, "MESSAGE/RFC822") == 0)
...@@ -865,7 +866,7 @@ bodystructure (message_t msg, int extension) ...@@ -865,7 +866,7 @@ bodystructure (message_t msg, int extension)
865 /* body encoding: Content-Transfer-Encoding. */ 866 /* body encoding: Content-Transfer-Encoding. */
866 header_aget_value (header, MU_HEADER_CONTENT_TRANSFER_ENCODING, &buffer); 867 header_aget_value (header, MU_HEADER_CONTENT_TRANSFER_ENCODING, &buffer);
867 util_send (" "); 868 util_send (" ");
868 util_send_qstring ((*buffer) ? buffer : "7BIT"); 869 util_send_qstring (buffer ? buffer : "7BIT");
869 free (buffer); 870 free (buffer);
870 871
871 /* body size RFC822 format. */ 872 /* body size RFC822 format. */
...@@ -1211,12 +1212,9 @@ fetch_header_fields (message_t msg, char **arg, unsigned long start, ...@@ -1211,12 +1212,9 @@ fetch_header_fields (message_t msg, char **arg, unsigned long start,
1211 { 1212 {
1212 char *value = NULL; 1213 char *value = NULL;
1213 size_t n = 0; 1214 size_t n = 0;
1214 header_aget_value (header, array[j], &value); 1215 if (header_aget_value (header, array[j], &value))
1215 if (*value == '\0')
1216 {
1217 free (value);
1218 continue; 1216 continue;
1219 } 1217
1220 n = asprintf (&buffer, "%s: %s\n", array[j], value); 1218 n = asprintf (&buffer, "%s: %s\n", array[j], value);
1221 status = stream_write (stream, buffer, n, off, &n); 1219 status = stream_write (stream, buffer, n, off, &n);
1222 off += n; 1220 off += n;
......
...@@ -46,10 +46,12 @@ mail_followup (int argc, char **argv) ...@@ -46,10 +46,12 @@ mail_followup (int argc, char **argv)
46 46
47 /* Create subject value */ 47 /* Create subject value */
48 message_get_header(msg, &hdr); 48 message_get_header(msg, &hdr);
49 header_aget_value(hdr, MU_HEADER_SUBJECT, &str); 49 if (header_aget_value(hdr, MU_HEADER_SUBJECT, &str) == 0)
50 {
50 util_strcat(&env.subj, "Re: "); 51 util_strcat(&env.subj, "Re: ");
51 util_strcat(&env.subj, str); 52 util_strcat(&env.subj, str);
52 free(str); 53 free(str);
54 }
53 55
54 /* Generate "to" list */ 56 /* Generate "to" list */
55 env.to = util_get_sender(cursor, 0); 57 env.to = util_get_sender(cursor, 0);
......
...@@ -57,11 +57,12 @@ mail_reply(int argc, char **argv) ...@@ -57,11 +57,12 @@ mail_reply(int argc, char **argv)
57 size_t i, count = 0; 57 size_t i, count = 0;
58 char buf[512]; 58 char buf[512];
59 59
60 header_aget_value(hdr, MU_HEADER_TO, &str); 60 if (header_aget_value(hdr, MU_HEADER_TO, &str) == 0)
61 61 {
62 address_create(&addr, str); 62 address_create(&addr, str);
63 free(str); 63 free(str);
64 address_get_count(addr, &count); 64 address_get_count(addr, &count);
65 }
65 66
66 /* Make sure we do not include our alternate names */ 67 /* Make sure we do not include our alternate names */
67 for (i = 1; i <= count; i++) 68 for (i = 1; i <= count; i++)
......