bugfix: was overwriting short constant string or argv
r3633 | dcl | 2012-07-11 11:56:25 +1000 (Wed, 11 Jul 2012) | 1 line
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <libiberty.h>
|
||||
/* #include <libiberty.h> */
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
@@ -43,7 +43,7 @@ int main(int argc, char* argv[])
|
||||
char errBuff[2048]={'\0'};
|
||||
struct timeval now;
|
||||
uint64 last_poll;
|
||||
char* device = DEFAULT_DEVICE;
|
||||
char device_name[132] = DEFAULT_DEVICE;
|
||||
uint dev_no;
|
||||
int port = DEFAULT_LISTEN_PORT;
|
||||
int idx = 1;
|
||||
@@ -70,7 +70,8 @@ int main(int argc, char* argv[])
|
||||
tolower(argv[idx][2]) == 'v' &&
|
||||
isdigit(argv[idx][3]))
|
||||
{
|
||||
device = argv[idx];
|
||||
strncpy(device_name, argv[idx], sizeof(device_name) - 1);
|
||||
device_name[sizeof(device_name) - 1] = '\0';
|
||||
++idx;
|
||||
}
|
||||
else if (tolower(argv[idx][0]) == 'p' &&
|
||||
@@ -78,7 +79,8 @@ int main(int argc, char* argv[])
|
||||
tolower(argv[idx][2]) == 'i' &&
|
||||
isdigit(argv[idx][3]))
|
||||
{
|
||||
device = argv[idx];
|
||||
strncpy(device_name, argv[idx], sizeof(device_name) - 1);
|
||||
device_name[sizeof(device_name) - 1] = '\0';
|
||||
++idx;
|
||||
}
|
||||
else
|
||||
@@ -94,13 +96,13 @@ int main(int argc, char* argv[])
|
||||
else
|
||||
return usage(argc, argv, "bad port");
|
||||
|
||||
dev_no = atoi(&device[3]);
|
||||
dev_no = atoi(&device_name[3]);
|
||||
sock_init();
|
||||
gettimeofday(&now, NULL);
|
||||
for (idx = 0; idx < MAX_DEVICES; ++idx)
|
||||
{
|
||||
sprintf(device, "dev%d/ctr%d", dev_no, idx);
|
||||
DEVICE_CHK(device_init(&devices[idx], device));
|
||||
sprintf(device_name, "dev%d/ctr%d", dev_no, idx);
|
||||
DEVICE_CHK(device_init(&devices[idx], device_name));
|
||||
sock_listen(port + idx, device_command, devices[idx]);
|
||||
devices[idx]->current_time = now;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user