Summary:ASTERISK-18828: CEL RADIUS garbage in attribute values
Reporter:Saeed Mohammadi (saeed)Labels:
Date Opened:2011-11-07 07:29:09.000-0600Date Closed:2016-01-06 12:04:41.000-0600
Versions: Frequency of
is duplicated byASTERISK-25647 bug of cel_radius.c: wrong point of ADD_VENDOR_CODE
Environment:Fedora 15 32 bit, radiusclient-ng-0.5.6-6.fc15.i686Attachments:( 0) cel_radius.c.patch
Description:The vendor specific attributes received by the radius server were showing garbage in value.
First guess was that secret is not set correctly on both sides. Checked, not the cause of issue.
Tracing the packet showed that among all VSA, some contain correct values such as EVENTTIME. Checking the code of cel_radius.c showed different method of calling rc_avpair_add. Those which has correct values were adding by direct call to this function but garbage data pairs were called using ADD_VENDORE_CODE.

#define ADD_VENDOR_CODE(x,y) (rc_avpair_add(rh, send, x, &y, strlen(y), VENDOR_CODE))

Parameter y is sending by its address while is a const char * when it is called

ADD_VENDOR_CODE(PW_AST_CIDNAME, record->caller_id_name)    ---> caller_id_name is const char *

So the function rc_avpair_add gets a pointer to pointer instead of a void *

the following line will fix this issues

#define ADD_VENDOR_CODE(x,y) (rc_avpair_add(rh, send, x, &y, strlen(y), VENDOR_CODE))
#define ADD_VENDOR_CODE(x,y) (rc_avpair_add(rh, send, x, y, strlen(y), VENDOR_CODE))

Besides that on the same issue is seen on the line which is calling rc_avpair_add for PW_USER_NAME

&record->channel_name     --->   record->channel_name
Comments:By: Matt Jordan (mjordan) 2011-12-28 12:04:06.206-0600

Please use "diff -u" or "svn diff" on all your patches.   Patches should be attached to the issue after signing a valid license agreement.  Patches which include alternate formatting or are supplied in the issue description are almost certainly going to be thrown out or ignored; there are too few hours in the day to wade through difficult-to-follow C code fixes without the help of diff -u. Thanks!

By: Matt Jordan (mjordan) 2012-02-09 16:58:14.030-0600

Suspended due to lack of activity. Please request a bug marshal in #asterisk-bugs on the IRC network irc.freenode.net to reopen the issue should you have the additional information requested.  Further information can be found at http://www.asterisk.org/developers/bug-guidelines

By: Saeed Mohammadi (saeed) 2012-08-02 16:09:25.667-0500

Patch to fix mis-usage of pointers