Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#2020 closed defect (fixed)

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

Description

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 (1)

comment:1 Changed 7 years ago by riza

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

In r5600:

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

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