[
https://issues.apache.org/jira/browse/TS-4313?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15221924#comment-15221924
]
ASF GitHub Bot commented on TS-4313:
------------------------------------
Github user maskit commented on a diff in the pull request:
https://github.com/apache/trafficserver/pull/542#discussion_r58230651
--- Diff: proxy/hdrs/MIME.cc ---
@@ -473,7 +473,8 @@ mime_hdr_set_accelerator_slotnum(MIMEHdrImpl *mh,
int32_t slot_id, uint32_t slot
inline void
mime_hdr_set_accelerators_and_presence_bits(MIMEHdrImpl *mh, MIMEField
*field)
{
- int slot_id, slot_num;
+ int slot_id;
+ ptrdiff_t slot_num;
--- End diff --
I could do that but I didn't because the check below is not exactly the
same as the another one.
If I use ``contains()`` here, the code would be like this:
``` c
if (slot_id != MIME_SLOTID_NONE) {
if (mh->m_first_fblock.contains(field)) {
slot_num = (field - &(mh->m_first_fblock.m_field_slots[0]));
if ((slot_num < 0) || (slot_num >= MIME_FIELD_SLOTNUM_UNKNOWN)) {
slot_num = MIME_FIELD_SLOTNUM_UNKNOWN;
}
} else {
slot_num = MIME_FIELD_SLOTNUM_UNKNOWN;
}
mime_hdr_set_accelerator_slotnum(mh, slot_id,
MIME_FIELD_SLOTNUM_UNKNOWN);
}
```
It's not so readable, isn't it?
> MIMEHdr fails to find header fields
> -----------------------------------
>
> Key: TS-4313
> URL: https://issues.apache.org/jira/browse/TS-4313
> Project: Traffic Server
> Issue Type: Bug
> Components: MIME
> Reporter: Masakazu Kitajo
> Assignee: Masakazu Kitajo
> Fix For: 6.2.0
>
>
> MIMEHdr fails to find a MIMEField occasionally due to improper type
> conversion.
> It happens if the lower 32 bits of addresses of m_field_slots are the same.
> The logic below picks up wrong block.
> mime_hdr_field_slotnum():
> {code}
> for (fblock = &(mh->m_first_fblock); fblock != NULL; fblock = fblock->m_next)
> {
> MIMEField *first = &(fblock->m_field_slots[0]);
> int block_slot = (int)(field - first); // in units of MIMEField
> if ((block_slot >= 0) && (block_slot < MIME_FIELD_BLOCK_SLOTS))
> {code}
> The type of block_slot should be intptr_t.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)