fixes a bug with a dangling pointer. Thanks to Peter Kjellerstedt for
the report and suggested fix.
*
***********************************************************************/
static char const RCSID[] =
*
***********************************************************************/
static char const RCSID[] =
-"$Id: radius.c,v 1.17 2002/10/01 09:27:50 fcusack Exp $";
+"$Id: radius.c,v 1.18 2002/11/13 18:19:26 fcusack Exp $";
#include "pppd.h"
#include "chap.h"
#include "pppd.h"
#include "chap.h"
/* Add user specified vp's */
if (rstate.avp)
/* Add user specified vp's */
if (rstate.avp)
- rc_avpair_insert(&send, NULL, rstate.avp);
+ rc_avpair_insert(&send, NULL, rc_avpair_copy(rstate.avp));
if (rstate.authserver) {
result = rc_auth_using_server(rstate.authserver,
if (rstate.authserver) {
result = rc_auth_using_server(rstate.authserver,
/* Add user specified vp's */
if (rstate.avp)
/* Add user specified vp's */
if (rstate.avp)
- rc_avpair_insert(&send, NULL, rstate.avp);
+ rc_avpair_insert(&send, NULL, rc_avpair_copy(rstate.avp));
/*
* make authentication with RADIUS server
/*
* make authentication with RADIUS server
/* Add user specified vp's */
if (rstate.avp)
/* Add user specified vp's */
if (rstate.avp)
- rc_avpair_insert(&send, NULL, rstate.avp);
+ rc_avpair_insert(&send, NULL, rc_avpair_copy(rstate.avp));
if (rstate.acctserver) {
result = rc_acct_using_server(rstate.acctserver,
if (rstate.acctserver) {
result = rc_acct_using_server(rstate.acctserver,
/* Add user specified vp's */
if (rstate.avp)
/* Add user specified vp's */
if (rstate.avp)
- rc_avpair_insert(&send, NULL, rstate.avp);
+ rc_avpair_insert(&send, NULL, rc_avpair_copy(rstate.avp));
if (rstate.acctserver) {
result = rc_acct_using_server(rstate.acctserver,
if (rstate.acctserver) {
result = rc_acct_using_server(rstate.acctserver,
/* Add user specified vp's */
if (rstate.avp)
/* Add user specified vp's */
if (rstate.avp)
- rc_avpair_insert(&send, NULL, rstate.avp);
+ rc_avpair_insert(&send, NULL, rc_avpair_copy(rstate.avp));
if (rstate.acctserver) {
result = rc_acct_using_server(rstate.acctserver,
if (rstate.acctserver) {
result = rc_acct_using_server(rstate.acctserver,
- * $Id: radiusclient.h,v 1.8 2002/07/25 16:29:16 dfs Exp $
+ * $Id: radiusclient.h,v 1.9 2002/11/13 18:19:26 fcusack Exp $
*
* Copyright (C) 1995,1996,1997,1998 Lars Fenneberg
*
*
* Copyright (C) 1995,1996,1997,1998 Lars Fenneberg
*
VALUE_PAIR *rc_avpair_new __P((int, void *, int, int));
VALUE_PAIR *rc_avpair_gen __P((AUTH_HDR *));
VALUE_PAIR *rc_avpair_get __P((VALUE_PAIR *, UINT4));
VALUE_PAIR *rc_avpair_new __P((int, void *, int, int));
VALUE_PAIR *rc_avpair_gen __P((AUTH_HDR *));
VALUE_PAIR *rc_avpair_get __P((VALUE_PAIR *, UINT4));
+VALUE_PAIR *rc_avpair_copy __P((VALUE_PAIR *));
void rc_avpair_insert __P((VALUE_PAIR **, VALUE_PAIR *, VALUE_PAIR *));
void rc_avpair_free __P((VALUE_PAIR *));
int rc_avpair_parse __P((char *, VALUE_PAIR **));
void rc_avpair_insert __P((VALUE_PAIR **, VALUE_PAIR *, VALUE_PAIR *));
void rc_avpair_free __P((VALUE_PAIR *));
int rc_avpair_parse __P((char *, VALUE_PAIR **));
- * $Id: avpair.c,v 1.2 2002/10/01 08:35:21 fcusack Exp $
+ * $Id: avpair.c,v 1.3 2002/11/13 18:19:26 fcusack Exp $
*
* Copyright (C) 1995 Lars Fenneberg
*
*
* Copyright (C) 1995 Lars Fenneberg
*
+/*
+ * Function: rc_avpair_copy
+ *
+ * Purpose: Return a copy of the existing list "p" ala strdup().
+ *
+ */
+VALUE_PAIR *rc_avpair_copy(VALUE_PAIR *p)
+{
+ VALUE_PAIR *vp, *fp = NULL, *lp = NULL;
+
+ while (p) {
+ vp = malloc(sizeof(VALUE_PAIR));
+ if (!vp) {
+ rc_log(LOG_CRIT, "rc_avpair_copy: out of memory");
+ return NULL; /* leaks a little but so what */
+ }
+ *vp = *p;
+ if (!fp)
+ fp = vp;
+ if (lp)
+ lp->next = vp;
+ lp = vp;
+ p = p->next;
+ }
+
+ return fp;
+}
+
/*
* Function: rc_avpair_insert
*
/*
* Function: rc_avpair_insert
*
vp = *a;
if ( p == (VALUE_PAIR *) NULL) /* run to end of "a" list */
vp = *a;
if ( p == (VALUE_PAIR *) NULL) /* run to end of "a" list */