summaryrefslogtreecommitdiff
path: root/execute.c
diff options
context:
space:
mode:
authorBen Fuhrmannek2015-02-06 22:43:16 +0100
committerBen Fuhrmannek2015-02-06 22:43:16 +0100
commitb8d1b6ccb5d67874d8637a273f73fd9ae1138f16 (patch)
tree773d015dccfb4236b44121fc73fae81f23b926be /execute.c
parent3741554097cc73f03a9a6a4fa4d65dc01c120bd8 (diff)
fixed newline detection for suhosin.mail.protect
Diffstat (limited to 'execute.c')
-rw-r--r--execute.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/execute.c b/execute.c
index bc7dc59..d2fdaba 100644
--- a/execute.c
+++ b/execute.c
@@ -751,7 +751,10 @@ int ih_mail(IH_HANDLER_PARAMS)
751 return (1); 751 return (1);
752 } 752 }
753 753
754 if (headers_len > 0 && headers && (strstr(headers,"\n\n") || strstr(headers,"\r\n\r\n")) ) { 754 if (headers_len > 0 && headers &&
755 (strstr(headers, "\n\n") || strstr(headers, "\n\r\n") /* double newline */
756 || *headers == '\n' || (headers[0] == '\r' && headers[1] == '\n') /* starts with newline */
757 )) {
755 suhosin_log(S_MAIL, "mail() - double newline in headers, possible injection, mail dropped"); 758 suhosin_log(S_MAIL, "mail() - double newline in headers, possible injection, mail dropped");
756 if (!SUHOSIN_G(simulation)) { 759 if (!SUHOSIN_G(simulation)) {
757 RETVAL_FALSE; 760 RETVAL_FALSE;
@@ -762,14 +765,14 @@ int ih_mail(IH_HANDLER_PARAMS)
762 /* check for spam attempts with buggy webforms */ 765 /* check for spam attempts with buggy webforms */
763 if (to_len > 0 && to) { 766 if (to_len > 0 && to) {
764 do { 767 do {
765 tmp = strchr(to, '\n'); 768 if ((tmp = strchr(to, '\n')) == NULL)
766 tmp = tmp == NULL ? strchr(to, '\r') : tmp; 769 tmp = strchr(to, '\r');
767 if (tmp == NULL) break; 770 if (tmp == NULL) break;
768 to = tmp+1; 771 to = tmp + 1;
769 if (isspace(*to)) continue; 772 if (!isspace(*to)) break;
770 } while (1); 773 } while (1);
771 if (tmp != NULL) { 774 if (tmp != NULL) {
772 suhosin_log(S_MAIL, "mail() - newline in to header, possible injection, mail dropped"); 775 suhosin_log(S_MAIL, "mail() - newline in To header, possible injection, mail dropped");
773 if (!SUHOSIN_G(simulation)) { 776 if (!SUHOSIN_G(simulation)) {
774 RETVAL_FALSE; 777 RETVAL_FALSE;
775 return (1); 778 return (1);
@@ -779,14 +782,14 @@ int ih_mail(IH_HANDLER_PARAMS)
779 782
780 if (subject_len > 0 && subject) { 783 if (subject_len > 0 && subject) {
781 do { 784 do {
782 tmp = strchr(subject, '\n'); 785 if ((tmp = strchr(subject, '\n')) == NULL)
783 tmp = tmp == NULL ? strchr(subject, '\r') : tmp; 786 tmp = strchr(subject, '\r');
784 if (tmp == NULL) break; 787 if (tmp == NULL) break;
785 subject = tmp+1; 788 subject = tmp + 1;
786 if (isspace(*subject)) continue; 789 if (!isspace(*subject)) break;
787 } while (1); 790 } while (1);
788 if (tmp != NULL) { 791 if (tmp != NULL) {
789 suhosin_log(S_MAIL, "mail() - newline in subject header, possible injection, mail dropped"); 792 suhosin_log(S_MAIL, "mail() - newline in Subject header, possible injection, mail dropped");
790 if (!SUHOSIN_G(simulation)) { 793 if (!SUHOSIN_G(simulation)) {
791 RETVAL_FALSE; 794 RETVAL_FALSE;
792 return (1); 795 return (1);