summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Baumann <p.baumann@jacobs-university.de>2010-09-01 15:44:30 +0200
committerwww-data <www-data@ubuntu.localdomain>2010-12-19 23:43:41 +0100
commitdfc7584869a55b0dca46a41a8396f94cd3212612 (patch)
tree6c2d14e5bfd7c520b394bee39101e24e9358ec41
parentd99d4f99a98436fc96d9d4e15f0e24c7a3ebdc9f (diff)
downloadrasdaman-upstream-dfc7584869a55b0dca46a41a8396f94cd3212612.zip
rasdaman-upstream-dfc7584869a55b0dca46a41a8396f94cd3212612.tar.gz
rasdaman-upstream-dfc7584869a55b0dca46a41a8396f94cd3212612.tar.xz
avoid buffer oflo in rasserver invocation, use ARG_MAX consistently (also in place of self-defined MAX_CMD_LEN)
-rw-r--r--rasmgr/rasmgr_srv.cc6
-rw-r--r--rasmgr/rasmgr_srv.hh9
2 files changed, 6 insertions, 9 deletions
diff --git a/rasmgr/rasmgr_srv.cc b/rasmgr/rasmgr_srv.cc
index 91c593c..057a39d 100644
--- a/rasmgr/rasmgr_srv.cc
+++ b/rasmgr/rasmgr_srv.cc
@@ -407,7 +407,7 @@ int RasServer::startServer()
sTypeString= serverType==SERVERTYPE_FLAG_RNP ? "--rnp" : sTypeString;
const char *rasmgrHost = ptrServerHost->useLocalHost() ? "localhost" : config.getHostName();
- char command[MAX_CMD_LEN+1];
+ char command[ARG_MAX+1];
const char *SPRINTF_FORMAT = "%s %s %s --rsn %s %s --lport %ld --mgr %s --mgrport %ld --connect %s %s";
// check for buffer oflo
unsigned int commandLen =
@@ -418,9 +418,9 @@ int RasServer::startServer()
+ 4 // aka strlen(config.getListenPort())
+ strlen(ptrDatabaseHost->getConnectionString())
+ strlen(extraParam);
- if (commandLen > MAX_CMD_LEN)
+ if (commandLen > ARG_MAX)
{
- TALK( "RasServer::startServer(): fatal error: command line can host " << MAX_CMD_LEN << " bytes, but needs " << commandLen << "." );
+ TALK( "RasServer::startServer(): fatal error: command line can host " << ARG_MAX << " bytes, but needs " << commandLen << "." );
std::cout<<"Error: rasserver command line too long, cannot launch. Disappointedly aborting server start." <<std::endl;
return RASSERVER_CMDLINEOFLO;
}
diff --git a/rasmgr/rasmgr_srv.hh b/rasmgr/rasmgr_srv.hh
index 4aae3ce..2e67520 100644
--- a/rasmgr/rasmgr_srv.hh
+++ b/rasmgr/rasmgr_srv.hh
@@ -43,9 +43,6 @@ rasdaman GmbH.
#define RASEXECUTABLE BINDIR"rasserver"
#define MAXREGULARCOUNTER 3
-/// maximum length of an OS command line (we set it above POSIX2_LINE_MAX)
-const unsigned long MAX_CMD_LEN = 4096;
-
/// return codes
const unsigned int RASSERVER_OK = 0;
const unsigned int RASSERVER_NODATABASEHOST = -1;
@@ -116,14 +113,14 @@ class RasServer
int downNow();
void clearPendingTransaction();
- char serverName[1000];
+ char serverName[ARG_MAX];
ServerHost *ptrServerHost;
bool isinternal;
char serverType; //'r','h'
long listenPort; // 'r' ->rpc prognum; 'h' ->TCP/IP port
- char extraParam[MAX_CMD_LEN];
+ char extraParam[ARG_MAX];
- char executableName[MAX_CMD_LEN];
+ char executableName[ARG_MAX];
DatabaseHost *ptrDatabaseHost;
//char connStr[100];