question about 1.1.6 client code: rc_config_init()
Hi, I'm currently trying to use the 1.1.6 client code to create an embedded client. Doing a code inspection of rc_config_init() in lib\config.c , the following code looks suspicious: SERVER *authservers; SERVER *acctservers; ..... ..... authservers = rc_conf_srv(rh, "authserver"); acctservers = rc_conf_srv(rh, "acctserver"); authservers = malloc(sizeof(SERVER)); acctservers = malloc(sizeof(SERVER)); I think it's trying to malloc space for server options in rh but this doesn't happen. The net result is that any subsequent configuration of authservers and acctservers in this function will be lost as soon as the function is exited. Likewise the mallocs can never be freed up. Have I understood this correctly? Not sure how fixes get put back into the code for the next release. If someone can let me know if there is a formal procedure, that would be great. Cheers, Adam. -- View this message in context: http://old.nabble.com/question-about-1.1.6-client-code%3A-rc_config_init%28%... Sent from the FreeRadius - Dev mailing list archive at Nabble.com.
Adam Lewis wrote:
Hi, I'm currently trying to use the 1.1.6 client code to create an embedded client. Doing a code inspection of rc_config_init() in lib\config.c , the following code looks suspicious:
Yup.
I think it's trying to malloc space for server options in rh but this doesn't happen. The net result is that any subsequent configuration of authservers and acctservers in this function will be lost as soon as the function is exited. Likewise the mallocs can never be freed up. Have I understood this correctly? Not sure how fixes get put back into the code for the next release. If someone can let me know if there is a formal procedure, that would be great.
Create a patch, and send it to the list. Alan DeKok.
Not sure what's the best way to go. The 'minumum impact' solution is to replace: authservers = rc_conf_srv(rh, "authserver"); acctservers = rc_conf_srv(rh, "acctserver"); authservers = malloc(sizeof(SERVER)); acctservers = malloc(sizeof(SERVER)); with something like: OPTION *option; option = find_option(rh, "authserver", OT_SRV); if (option != NULL) { option->val = malloc(sizeof(SERVER)); authservers = option->val; } else { rc_log(LOG_CRIT, "rc_config_init: authserver option missing"); rc_destroy(rh); return NULL; } option = find_option(rh, "acctserver", OT_SRV); if (option != NULL) { option->val = malloc(sizeof(SERVER)); acctservers = option->val; } else { rc_log(LOG_CRIT, "rc_config_init: acctserver option missing"); rc_destroy(rh); return NULL; } alternatively you could move all the authserver & acctserver config from rc_config_init() to the "if (serv == null)" clause in set_option_srv(). Apologies for not providing a proper patch. I'm being pulled off this project for the moment. Regards, Adam. Alan DeKok-2 wrote:
Adam Lewis wrote:
Hi, I'm currently trying to use the 1.1.6 client code to create an embedded client. Doing a code inspection of rc_config_init() in lib\config.c , the following code looks suspicious:
Yup.
....
Create a patch, and send it to the list.
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/devel.html
-- View this message in context: http://old.nabble.com/question-about-1.1.6-client-code%3A-rc_config_init%28%... Sent from the FreeRadius - Dev mailing list archive at Nabble.com.
participants (2)
-
Adam Lewis -
Alan DeKok