opensips/opensips.patch.reg

Fri, 03 Aug 2012 20:11:53 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 03 Aug 2012 20:11:53 +0200
changeset 470
f8813e60f168
parent 382
b972dc20871f
child 547
1c75a8bb0fec
permissions
-rw-r--r--

Neutralize buggy code causing OpenPKG to have 'fatal problems' in
spite of correct installation, configuration, and operation. An
administrator suffering from this failure is even unable to
uninstall the flawed software.

     1 Index: modules/registrar/save.c
     2 diff -Nau modules/registrar/save.c.orig modules/registrar/save.c
     3 --- modules/registrar/save.c.orig	2008-08-03 15:53:57.000000000 +0200
     4 +++ modules/registrar/save.c	2009-03-24 21:44:46.182865192 +0100
     5 @@ -76,7 +76,7 @@
     6  struct save_ctx {
     7  	unsigned int flags;
     8  	str aor;
     9 -	unsigned int max_contacts;
    10 +	int max_contacts;
    11  };
    14 @@ -388,7 +388,7 @@
    15  		if (e == 0)
    16  			continue;
    18 -		if (_sctx->max_contacts && (num >= _sctx->max_contacts)) {
    19 +		if (_sctx->max_contacts && (num >= abs(_sctx->max_contacts))) {
    20  			if (_sctx->flags&REG_SAVE_FORCE_REG_FLAG) {
    21  				/* we are overflowing the number of maximum contacts,
    22  				   so remove the first (oldest) one to prevent this */
    23 @@ -494,6 +494,7 @@
    24  										contact_t* _c, struct save_ctx *_sctx)
    25  {
    26  	ucontact_info_t *ci;
    27 +	ucontact_t *ucon = 0;
    28  	ucontact_t* c;
    29  	int e;
    30  	unsigned int cflags;
    31 @@ -554,7 +555,7 @@
    32  				continue;
    34  			/* we need to add a new contact -> too many ?? */
    35 -			if (_sctx->max_contacts && num>=_sctx->max_contacts) {
    36 +			if (_sctx->max_contacts && num>=abs(_sctx->max_contacts)) {
    37  				if (_sctx->flags&REG_SAVE_FORCE_REG_FLAG) {
    38  					/* we are overflowing the number of maximum contacts,
    39  					   so remove the first (oldest) one to prevent this */
    40 @@ -581,6 +582,23 @@
    41  				goto error;
    42  			}
    44 +			/* remove matching contacts or matching Call-ID headers before */
    45 +			/* inserting a new one if indicated by a negative max_contacts */
    46 +			if (_sctx->max_contacts < 0) {
    47 +				for (ucon = _r->contacts; ucon; ucon = ucon->next) {
    48 +					if (((ci->callid->len == ucon->callid.len) && \
    49 +						!memcmp(ci->callid->s, ucon->callid.s, ci->callid->len)) \
    50 +						|| \
    51 +						((_c->uri.len==ucon->c.len) && \
    52 +						!memcmp(_c->uri.s, ucon->c.s, _c->len))) {
    53 +						if (ul.delete_ucontact(_r, ucon) < 0) {
    54 +							rerrno = R_UL_DEL_C;
    55 +							LM_ERR("failed to delete contact\n");
    56 +							goto error;
    57 +						}
    58 +					} 
    59 +				} 
    60 +			} 
    61  			if (ul.insert_ucontact( _r, &_c->uri, ci, &c) < 0) {
    62  				rerrno = R_UL_INS_C;
    63  				LM_ERR("failed to insert contact\n");
    64 Index: modules/registrar/sip_msg.c
    65 diff -Nau modules/registrar/sip_msg.c.orig modules/registrar/sip_msg.c
    66 --- modules/registrar/sip_msg.c.orig	2008-08-03 15:53:57.000000000 +0200
    67 +++ modules/registrar/sip_msg.c	2009-03-24 21:44:46.182865192 +0100
    68 @@ -137,7 +137,7 @@
    69  	/* Message without contacts is OK */
    70  	if (_m->contact == 0) return 0;
    72 -	if (((contact_body_t*)_m->contact->parsed)->star == 1) {
    73 +	if (((contact_body_t*)_m->contact->parsed)->star == -1) {
    74  		/* The first Contact HF is star */
    75  		/* Expires must be zero */
    76  		if (get_expires_hf(_m) > 0) {
    77 @@ -167,7 +167,7 @@
    78  		p = _m->contact->next;
    79  		while(p) {
    80  			if (p->type == HDR_CONTACT_T) {
    81 -				if (((contact_body_t*)p->parsed)->star == 1) {
    82 +				if (((contact_body_t*)p->parsed)->star == -1) {
    83  					rerrno = R_STAR_CONT;
    84  					return 1;
    85  				}

mercurial