Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfluebben committed Nov 9, 2010
1 parent 4201e30 commit 09af88f
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 11 deletions.
12 changes: 9 additions & 3 deletions AccountingProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ void AccountingProcess::Accounting(PluginContext * context)
int AccountingProcess::callVsaScript(PluginContext * context, User * user, unsigned int action, unsigned int rekeying)
{
char * route;
Octet * buf;
int buflen = 3 * sizeof(int);
if (user->getUsername().length() != 0)
{
Expand Down Expand Up @@ -366,9 +367,14 @@ int AccountingProcess::callVsaScript(PluginContext * context, User * user, unsig
buflen=buflen+strlen(route)+2*sizeof(int);
}
}

Octet * buf = new Octet[buflen];
unsigned int value = htonl(action);
try{
buf = new Octet[buflen];
}
catch(...)
{
cerr << getTime() << "RADIUS-PLUGIN: BACKGROUND ACCT: New failed for framedroutes buf." << endl;
}
unsigned int value = htonl(action);
memcpy(buf,&value, 4);

value = htonl(rekeying);
Expand Down
14 changes: 13 additions & 1 deletion IpcSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ string IpcSocket::recvStr(void)
}
if(len > 0)
{
buffer=new char[len+1];
try{
buffer=new char[len+1];
}
catch(...)
{
cerr << "RADIUS-PLUGIN: BACKGROUND ACCT: New failed for buffer in IpcSocket::recvStr." << endl;
}
memset (buffer, 0, len+1);
size = read (this->socket, buffer, len);
if (size!=len)
Expand Down Expand Up @@ -214,7 +220,13 @@ void IpcSocket::recvBuf(User * user)
user->setVsaBufLen(len);
if (len > 0)
{
try{
user->setVsaBuf(new Octet[len]);
}
catch(...)
{
cerr << "RADIUS-PLUGIN: BACKGROUND ACCT: New failed for buffer in IpcSocket::recvBuf." << endl;
}
size = read (this->socket, user->getVsaBuf(), len);
if (size != len)
{
Expand Down
2 changes: 2 additions & 0 deletions IpcSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#ifndef _IPCSOCKET_H_
#define _IPCSOCKET_H_

//#include "radiusplugin.h"
#include <string>
#include <cstring>
#include "User.h"
Expand All @@ -31,6 +32,7 @@
#include <arpa/inet.h>
#include <unistd.h>


typedef unsigned char Octet;

/** This class implements the inter process communication
Expand Down
36 changes: 31 additions & 5 deletions User.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@ User & User::operator=(const User & u)
this->vsabuflen=u.vsabuflen;
if(u.vsabuf != NULL)
{
this->vsabuf=new Octet[this->vsabuflen];
try{
this->vsabuf=new Octet[this->vsabuflen];
}
catch(...)
{
cerr << "RADIUS-PLUGIN: BACKGROUND ACCT: New failed for vsabuflen." << endl;
}


memcpy(this->vsabuf, u.vsabuf, this->vsabuflen);
}
else
Expand Down Expand Up @@ -114,7 +122,13 @@ User::User(const User & u)
this->vsabuflen=u.vsabuflen;
if(u.vsabuf != NULL)
{
this->vsabuf=new Octet[this->vsabuflen];
try{
this->vsabuf=new Octet[this->vsabuflen];
}
catch(...)
{
cerr << "RADIUS-PLUGIN: BACKGROUND ACCT: New failed for vsabuflen." << endl;
}
memcpy(this->vsabuf, u.vsabuf, this->vsabuflen);
}
else
Expand Down Expand Up @@ -271,8 +285,14 @@ void User::setUntrustedPort(string port)
int User::appendVsaBuf(Octet *value, unsigned int len)
{
if(this->vsabuf == NULL)
{
this->vsabuf=new Octet[len];
{
try{
this->vsabuf=new Octet[len];
}
catch(...)
{
cerr << "RADIUS-PLUGIN: BACKGROUND ACCT: New failed for vsabuflen." << endl;
}
memcpy(this->vsabuf, value, len);
this->vsabuflen=len;
}
Expand All @@ -281,7 +301,13 @@ int User::appendVsaBuf(Octet *value, unsigned int len)
Octet old_vsa[this->vsabuflen];
memcpy(old_vsa, this->vsabuf, this->vsabuflen);
delete [] this->vsabuf;
this->vsabuf=new Octet[this->vsabuflen+len];
try{
this->vsabuf=new Octet[this->vsabuflen+len];
}
catch(...)
{
cerr << "RADIUS-PLUGIN: BACKGROUND ACCT: New failed for vsabuflen." << endl;
}
memcpy(this->vsabuf, old_vsa, this->vsabuflen);
memcpy((this->vsabuf+this->vsabuflen), value, len);
this->vsabuflen=this->vsabuflen+len;
Expand Down
1 change: 1 addition & 0 deletions User.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <iostream>
#include <cstdio>
#include <cstring>
//#include "radiusplugin.h"
//#include "openvpn-plugin.h"


Expand Down
16 changes: 14 additions & 2 deletions UserAcct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,13 @@ void UserAcct::delSystemRoutes(PluginContext * context)

//copy the framed route string to an char array, it is easier to
//analyse
framedroutes=new char[this->getFramedRoutes().size()+1];
try{
framedroutes=new char[this->getFramedRoutes().size()+1];
}
catch(...)
{
cerr << getTime() << "RADIUS-PLUGIN: BACKGROUND ACCT: New failed for framedroutes." << endl;
}
memset(framedroutes,0,this->getFramedRoutes().size()+1);

// copy in a temp-string, because strtok deletes the delimiter, if it used anywhere
Expand Down Expand Up @@ -763,7 +769,13 @@ void UserAcct::addSystemRoutes(PluginContext * context)

//copy the framed route string to an char array, it is easier to
//analyse
framedroutes=new char[this->getFramedRoutes().size()+1];
try{
framedroutes=new char[this->getFramedRoutes().size()+1];
}
catch(...)
{
cerr << getTime() << "RADIUS-PLUGIN: BACKGROUND ACCT: New failed for framedroutes." << endl;
}
memset(framedroutes,0,this->getFramedRoutes().size()+1);

// copy in a temp-string, becaue strtok deletes the delimiter, if it used anywhere
Expand Down

0 comments on commit 09af88f

Please sign in to comment.