Don't limit refclock driver name to 4 chars

This commit is contained in:
Miroslav Lichvar 2011-06-13 13:49:46 +02:00
parent 0bf34725e3
commit 31ba3144c8
3 changed files with 20 additions and 8 deletions

18
conf.c
View file

@ -471,7 +471,7 @@ parse_refclock(const char *line)
unsigned long ref_id, lock_ref_id;
double offset, delay, precision;
const char *tmp;
char name[5], cmd[10 + 1], *param;
char cmd[10 + 1], *name, *param;
unsigned char ref[5];
SRC_SelectOption sel_option;
@ -490,11 +490,20 @@ parse_refclock(const char *line)
lock_ref_id = 0;
sel_option = SRC_SelectNormal;
if (sscanf(line, "%4s%n", name, &n) != 1) {
while (isspace(line[0]))
line++;
tmp = line;
while (line[0] != '\0' && !isspace(line[0]))
line++;
if (line == tmp) {
LOG(LOGS_WARN, LOGF_Configure, "Could not read refclock driver name at line %d", line_number);
return;
}
line += n;
name = MallocArray(char, 1 + line - tmp);
strncpy(name, tmp, line - tmp);
name[line - tmp] = '\0';
while (isspace(line[0]))
line++;
@ -504,6 +513,7 @@ parse_refclock(const char *line)
if (line == tmp) {
LOG(LOGS_WARN, LOGF_Configure, "Could not read refclock parameter at line %d", line_number);
Free(name);
return;
}
@ -558,7 +568,7 @@ parse_refclock(const char *line)
line += n;
}
strncpy(refclock_sources[i].driver_name, name, 4);
refclock_sources[i].driver_name = name;
refclock_sources[i].driver_parameter = param;
refclock_sources[i].driver_poll = dpoll;
refclock_sources[i].poll = poll;

View file

@ -150,14 +150,14 @@ RCL_AddRefclock(RefclockParameters *params)
if (n_sources == MAX_RCL_SOURCES)
return 0;
if (strncmp(params->driver_name, "SHM", 4) == 0) {
if (strcmp(params->driver_name, "SHM") == 0) {
inst->driver = &RCL_SHM_driver;
inst->precision = 1e-6;
} else if (strncmp(params->driver_name, "SOCK", 4) == 0) {
} else if (strcmp(params->driver_name, "SOCK") == 0) {
inst->driver = &RCL_SOCK_driver;
inst->precision = 1e-9;
pps_source = 1;
} else if (strncmp(params->driver_name, "PPS", 4) == 0) {
} else if (strcmp(params->driver_name, "PPS") == 0) {
inst->driver = &RCL_PPS_driver;
inst->precision = 1e-9;
pps_source = 1;
@ -244,6 +244,8 @@ RCL_AddRefclock(RefclockParameters *params)
#endif
n_sources++;
Free(params->driver_name);
return 1;
}

View file

@ -32,7 +32,7 @@
#include "sources.h"
typedef struct {
char driver_name[4];
char *driver_name;
char *driver_parameter;
int driver_poll;
int poll;