static void unique_add_attr(int dictattr) {
struct unique_attr_list *new;
- if((new = malloc(sizeof(struct unique_attr_list))) == NULL) {
- radlog(L_ERR, "rlm_acct_unique: out of memory");
- exit(1);
- }
+ new = rad_malloc(sizeof(struct unique_attr_list));
+
memset((struct unique_attr_list *)new, 0, sizeof(unique_attr_list));
/* Assign the attr to our new structure */
/*
* Set up a storage area for instance data
*/
- if ((inst = malloc(sizeof(*inst))) == NULL) {
- radlog(L_ERR, "rlm_acct_unique: out of memory");
- return -1;
- }
+ inst = rad_malloc(sizeof(*inst));
memset(inst, 0, sizeof(*inst));
if (cf_section_parse(conf, module_config) < 0) {
/*
* Set up a storage area for instance data
*/
- data = malloc(sizeof(*data));
- if (!data) {
- radlog(L_ERR, "rlm_always: out of memory");
- return -1;
- }
+ data = rad_malloc(sizeof(*data));
/*
* Copy the configuration into the instance data
#include <fcntl.h>
#include <limits.h>
-#if HAVE_MALLOC_H
-# include <malloc.h>
-#endif
-
#ifdef HAVE_REGEX_H
# include <regex.h>
#endif
struct attr_filter_instance *inst;
int rcode;
- inst = malloc(sizeof *inst);
- if (!inst) {
- radlog(L_ERR|L_CONS, "Out of memory\n");
- return -1;
- }
+ inst = rad_malloc(sizeof *inst);
if (cf_section_parse(conf, module_config) < 0) {
free(inst);
/*
* Set up a storage area for instance data
*/
- data = malloc(sizeof(*data));
- if (!data) {
- return -1;
- }
+ data = rad_malloc(sizeof(*data));
/*
* Copy the configuration into the instance data
#include <fcntl.h>
#include <limits.h>
-#if HAVE_MALLOC_H
-# include <malloc.h>
-#endif
-
#include "radiusd.h"
#include "modules.h"
* Allocate space for hash table here
*/
memsize = sizeof(PAIR_LIST *) * inst->hashsize;
- if( (newhash = (PAIR_LIST **)malloc(memsize)) == NULL) {
- radlog(L_ERR, "rlm_fastusers: Can't build hashtable, out of memory!");
- return -1;
- }
+
+ newhash = (PAIR_LIST **) rad_malloc(memsize);
+
memset((PAIR_LIST *)newhash, 0, memsize);
/* Read acct_users */
{
struct fastuser_instance *inst=0;
- inst = malloc(sizeof *inst);
- if (!inst) {
- radlog(L_ERR|L_CONS, "Out of memory\n");
- return -1;
- }
+ inst = rad_malloc(sizeof *inst);
+
memset(inst, 0, sizeof(inst));
if (cf_section_parse(conf, module_config) < 0) {
#include <fcntl.h>
#include <limits.h>
-#if HAVE_MALLOC_H
-# include <malloc.h>
-#endif
-
#include "radiusd.h"
#include "modules.h"
struct file_instance *inst;
int rcode;
- inst = malloc(sizeof *inst);
- if (!inst) {
- radlog(L_ERR|L_CONS, "Out of memory\n");
- return -1;
- }
+ inst = rad_malloc(sizeof *inst);
if (cf_section_parse(conf, module_config) < 0) {
free(inst);
#include <stdlib.h>
#include <string.h>
-#if HAVE_MALLOC_H
-# include <malloc.h>
-#endif
-
#include "radiusd.h"
#include "modules.h"
int r;
krb5_context *context;
- context = malloc(sizeof(*context));
- if (!context) {
- radlog(L_ERR|L_CONS, "Out of memory\n");
- return -1;
- }
+ context = rad_malloc(sizeof(*context));
if ((r = krb5_init_context(context)) ) {
radlog(L_AUTH, "rlm_krb5: krb5_init failed: %s",
{
ldap_instance *inst;
- inst = malloc(sizeof *inst);
- if (!inst) {
- radlog(L_ERR | L_CONS, "rlm_ldap: Out of memory\n");
- return -1;
- }
+ inst = rad_malloc(sizeof *inst);
+
if (cf_section_parse(conf, module_config) < 0) {
free(inst);
return -1;
#include <security/pam_appl.h>
-#if HAVE_MALLOC_H
-# include <malloc.h>
-#endif
-
#include "radiusd.h"
#include "modules.h"
return -1;
}
- data = malloc(sizeof(*data));
- if (!data) {
- radlog(L_ERR|L_CONS, "rlm_pam: Out of memory\n");
- return -1;
- }
+ data = rad_malloc(sizeof(*data));
data->pam_auth_name = config.pam_auth_name;
config.pam_auth_name = NULL;
int size = sizeof(struct pam_response);
my_PAM *pam_config = (my_PAM *) appdata_ptr;
-#define GET_MEM if (reply) realloc(reply, size); else reply = malloc(size); \
- if (!reply) return PAM_CONV_ERR; \
+#define GET_MEM if (reply) realloc(reply, size); else reply = rad_malloc(size); \
size += sizeof(struct pam_response)
#define COPY_STRING(s) ((s) ? strdup(s) : NULL)
#include <string.h>
#include <ctype.h>
-#if HAVE_MALLOC_H
-# include <malloc.h>
-#endif
-
#include "radiusd.h"
#include "modules.h"
/*
* Allocate room to put the module's instantiation data.
*/
- data = (rlm_preprocess_t *) malloc(sizeof(*data));
- if (!data) {
- radlog(L_ERR|L_CONS, "Out of memory\n");
- return -1;
- }
+ data = (rlm_preprocess_t *) rad_malloc(sizeof(*data));
/*
* Copy the configuration over to the instantiation.
data->ascend_channels_per_line);
}
- hints_setup(data->hints, request);
-
/*
* Note that we add the Request-Src-IP-Address to the request
* structure BEFORE checking huntgroup access. This allows
*/
add_nas_attr(request);
+ hints_setup(data->hints, request);
+
if (huntgroup_access(data->huntgroups, request->packet->vps) != RLM_MODULE_OK) {
radlog(L_AUTH, "No huntgroup access: [%s] (%s)",
request->username->strvalue,
* authentication && accounting.
*/
rad_mangle(data, request);
- r = hints_setup(data->hints, request);
/*
* Ensure that we log the NAS IP Address in the packet.
*/
add_nas_attr(request);
+ r = hints_setup(data->hints, request);
+
return r;
}
#include "config.h"
-#if HAVE_MALLOC_H
-# include <malloc.h>
-#endif
-
#include "radiusd.h"
#include "radutmp.h"
#include "modules.h"
if (r >= 0 && (status == PW_STATUS_START ||
status == PW_STATUS_ALIVE)) {
if (cache == NULL) {
- if ((cache = malloc(sizeof(NAS_PORT))) != NULL) {
- cache->nasaddr = ut.nas_address;
- cache->port = ut.nas_port;
- cache->offset = off;
- cache->next = inst->nas_port_list;
- inst->nas_port_list = cache;
- }
+ cache = rad_malloc(sizeof(NAS_PORT));
+ cache->nasaddr = ut.nas_address;
+ cache->port = ut.nas_port;
+ cache->offset = off;
+ cache->next = inst->nas_port_list;
+ inst->nas_port_list = cache;
}
ut.type = P_LOGIN;
write(fd, &ut, sizeof(u));
struct realm_config_t *inst;
/* setup a storage area for instance data */
- inst = malloc(sizeof(struct realm_config_t));
- if(!inst) {
- radlog(L_ERR|L_CONS, "Out of memory\n");
- return -1;
- }
+ inst = rad_malloc(sizeof(struct realm_config_t));
if(cf_section_parse(conf, module_config) < 0) {
free(inst);
{
SQLSOCK *socket;
- if((socket = malloc(sizeof(SQLSOCK))) == NULL) {
- radlog(L_CONS|L_ERR, "sql_create_socket: no memory");
- exit(1);
- }
+ socket = rad_malloc(sizeof(SQLSOCK));
if(SQLAllocEnv(&socket->env_handle) != SQL_SUCCESS) {
radlog(L_CONS|L_ERR, "sql_create_socket: SQLAllocEnv failed: %s",
numfields = sql_num_fields(socket);
- if( (row = (char **)malloc(sizeof(char *) * numfields)) == NULL) {
- radlog(L_ERR, "sql_select_query: Out of memory!");
- return -1;
- }
+ row = (char **) rad_malloc(sizeof(char *) * numfields);
memset(row, 0, (sizeof(char *) * (numfields)));
row[numfields-1] = NULL;
/*
* Allocate space for each column
*/
- row[i-1] = (SQLCHAR*)malloc((int)len);
+ row[i-1] = (SQLCHAR*)rad_malloc((int)len);
/*
* This makes me feel dirty, but, according to Microsoft, it works.
{
SQLSOCK *socket;
- if ((socket = malloc(sizeof(SQLSOCK))) == NULL) {
- radlog(L_CONS|L_ERR, "sql_create_socket: no memory");
- exit(1);
- }
+ socket = rad_malloc(sizeof(SQLSOCK));
if (OCIEnvCreate(&socket->env, OCI_DEFAULT, (dvoid *)0,
(dvoid * (*)(dvoid *, size_t)) 0,
/* DEBUG2("sql_select_query(): colcount=%d",colcount); */
- rowdata=(char **)malloc(sizeof(char *) * (colcount+1) );
+ rowdata=(char **)rad_malloc(sizeof(char *) * (colcount+1) );
memset(rowdata, 0, (sizeof(char *) * (colcount+1) ));
for (y=1; y <= colcount; y++) {
sql_error(socket));
return -1;
}
- rowdata[y-1]=malloc(dsize+1);
+ rowdata[y-1]=rad_malloc(dsize+1);
break;
case SQLT_DAT:
case SQLT_INT:
case SQLT_PDN:
case SQLT_BIN:
case SQLT_NUM:
- rowdata[y-1]=malloc(dsize+1);
+ rowdata[y-1]=rad_malloc(dsize+1);
break;
default:
dsize=0;
SQL_INST *inst;
- if ((inst = malloc(sizeof(SQL_INST))) == NULL) {
- radlog(L_ERR | L_CONS, "sql_instantiate: no memory");
- return -1;
- }
+ inst = rad_malloc(sizeof(SQL_INST));
memset(inst, 0, sizeof(SQL_INST));
- if ((inst->config = malloc(sizeof(SQL_CONFIG))) == NULL) {
- radlog(L_ERR | L_CONS, "sql_instantiate: no memory");
- free(inst);
- return -1;
- }
+
+ inst->config = rad_malloc(sizeof(SQL_CONFIG));
memset(inst->config, 0, sizeof(SQL_CONFIG));
#if HAVE_PTHREAD_H
- inst->lock = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
- if (inst->lock == NULL)
- return -1;
+ inst->lock = (pthread_mutex_t *) rad_malloc(sizeof(pthread_mutex_t));
pthread_mutex_init(inst->lock, NULL);
- inst->notfull = (pthread_cond_t *) malloc(sizeof(pthread_cond_t));
+ inst->notfull = (pthread_cond_t *) rad_malloc(sizeof(pthread_cond_t));
pthread_cond_init(inst->notfull, NULL);
#endif
} else {
sqlsocket->id = i;
#if HAVE_PTHREAD_H
- sqlsocket->semaphore = (sem_t *) malloc(sizeof(sem_t));
+ sqlsocket->semaphore = (sem_t *) rad_malloc(sizeof(sem_t));
sem_init(sqlsocket->semaphore, 0, SQLSOCK_UNLOCKED);
#else
sqlsocket->in_use = 0;
SQLSOCK *sqlsocket;
- if ((sqlsocket = malloc(sizeof(SQLSOCK))) == NULL) {
- radlog(L_CONS | L_ERR, "sql_create_socket: no memory");
- exit(1);
- }
+ sqlsocket = rad_malloc(sizeof(SQLSOCK));
mysql_init(&(sqlsocket->conn));
if (!
#include "config.h"
-#if HAVE_MALLOC_H
-# include <malloc.h>
-#endif
-
#if HAVE_SHADOW_H
# include <shadow.h>
#endif
/*
* Allocate room for the instance.
*/
- inst = *instance = malloc(sizeof(struct unix_instance));
- if(!inst) {
- return -1;
- }
+ inst = *instance = rad_malloc(sizeof(struct unix_instance));
/*
* Copy the configuration into the instance data