Browse Source

[Fix] Fix parsing of the received headers with empty part

tags/2.0
Vsevolod Stakhov 4 years ago
parent
commit
c1f9bfc863
2 changed files with 20 additions and 5 deletions
  1. 12
    4
      src/libmime/mime_headers.c
  2. 8
    1
      test/lua/unit/received.lua

+ 12
- 4
src/libmime/mime_headers.c View File

@@ -1098,8 +1098,14 @@ rspamd_smtp_received_process_part (struct rspamd_task *task,
p ++;
break;
case all_done:
*last = p - (const guchar *)data;
return npart;
if (p > (const guchar *)data) {
*last = p - (const guchar *) data;
return npart;
}
else {
/* Empty element */
return NULL;
}
break;
}
}
@@ -1120,9 +1126,11 @@ rspamd_smtp_received_process_part (struct rspamd_task *task,
}
break;
case skip_spaces:
*last = p - (const guchar *)data;
if (p > c) {
*last = p - (const guchar *) data;

return npart;
return npart;
}
default:
break;
}

+ 8
- 1
test/lua/unit/received.lua View File

@@ -121,7 +121,14 @@ context("Received headers parser", function()
{
by_hostname = 'example.com',
},
}
},
{[[from 171-29.br (1-1-1-1.z.com.br [1.1.1.1]) by x.com.br (Postfix) with;ESMTP id 44QShF6xj4z1X for <y.br>; Thu, 21 Mar 2019 23:45:46 -0300 : <g @yi.br>]],
{
from_hostname = '171-29.br',
real_ip = '1.1.1.1',
by_hostname = 'x.com.br',
}
},
}

local task = ffi.C.rspamd_task_new(nil, nil)

Loading…
Cancel
Save