Ticket #2020 (closed defect: fixed)

Opened 20 months ago

Last modified 20 months ago

pj_hash_calc_tolower() might return a different hash value

Reported by: riza Owned by: bennylp
Priority: normal Milestone: release-2.7
Component: pjlib Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported: no


Example scenario:

  1. Received INVITE with branch=z9hG4bK%999999f
  2. Respond with 100
  3. Respond with 180
  4. Received CANCEL
  5. Respond with "481 Call/Transaction Does Not Exist"

By default, sip_transaction.c enabled PRECALC_HASH which calculated the hash value using pj_hash_calc_lower().

char lower = (char)pj_tolower(key->ptr[i]);

When setting the hash, the value was calculated using

const pj_uint8_t *p = (const pj_uint8_t*)key,*end = p + keylen;
hash = hash * PJ_HASH_MULTIPLIER + pj_tolower(*p);

The branch/key contain %99, which will be stored as 0x99, the calculated hash value will differ.

Thanks to Fredrik Hansson for the report.

Change History

comment:1 Changed 20 months ago by riza

  • Status changed from new to closed
  • Resolution set to fixed

In r5600:

Fixed #2020: Method pj_hash_calc_tolower() might return a different hash value.

Last edited 20 months ago by riza (previous) (diff)
Note: See TracTickets for help on using tickets.