Bill,

On 04/03/2019 15:11, Bill Cole wrote:
> On 4 Mar 2019, at 6:58, Vsevolod Stakhov wrote:
> 
>> Hello,
>>
>> I'm trying to debug one issue with the milter interface in Postfix. I
>> want to remove multiple headers with the same name, for example:
>>
>> X-Spam-Flag: No
>> X-Spam-Flag: No
>> X-Spam-Flag: Not really
>> X-Spam-Flag: No
>>
>> To do that, I track headers on header phase and track numbers for each
>> header. For this particular sample, I will have some map like
>> `X-Spam-Flag = 4`.
>>
>> After end-of-data stage, I send multiple `CHGHEADER` ('m') commands with
>> header value equal to a empty string:
>>
>> change/insert header command pos = 1 - "X-Spam-Flag"=""
>> change/insert header command pos = 2 - "X-Spam-Flag"=""
>> change/insert header command pos = 3 - "X-Spam-Flag"=""
>> change/insert header command pos = 4 - "X-Spam-Flag"=""
>>
>> Literally, my code (Rspamd) sends CHGHEADER command 4 times. After
>> message being processed, I can see that Postfix removes 2 of 4
>> `X-Spam-Flag` headers.
>>
>> I have tested something else after that. I have tried to add more
>> headers where names are equal and non equal. It seems that all odd
>> headers are not removed.
> 
> I have not tested this, but your description is consistent with the
> Milter interface acting immediately on your deletion of the indexed
> header instance and collapsing the array, modifying which index points
> to which data. So, after you delete the 1st "X-Spam-Flag" header, you
> now have 3 instances remaining, with the new 1st instance being the
> former 2nd instance. This way, if you delete the 2nd instance, you are
> deleting what WAS the 3rd.

It is not consistent with the Sendmail behaviour:

https://groups.google.com/forum/#!msg/comp.mail.sendmail/Xgl1DE3lTUg/_uaAEmTM8EYJ

For me, it doesn't make any difference to send `1` 4 times instead of
sending `1, 2, 3, 4` sequence. But I'm worried not to break other MTAs
that use milter protocol.

> In any event, the results described also imply that you are not
> bothering to check for errors when you call a library routine that CAN
> return an error. 

I don't call any library, I have my own implementation of the milter
protocol. It checks for any errors that could arise but there are no
errors of course, or I would have not asked this question.

> Again, I have not tested this but I know that chgheader
> CAN return an error and would expect it to do so when passed an
> out-of-range index.
> 
> Return values exist for good reasons. One of them is to help novice
> coders avoid public embarrassment.

JFYI, calling other people novice coders without knowing the real
background could also lead to a public embarrassment.

Reply via email to