diff options
author | Keith Packard <keithp@keithp.com> | 2009-07-05 08:35:28 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-07-05 08:35:28 -0700 |
commit | 19630ef084866f4230e68ccf11284b30c68128b1 (patch) | |
tree | 7bdcbc867d05067c19d1f71a41fd1e4f4612b65e | |
parent | e506ed4b6efb86eab50204658fcd433b987e3831 (diff) |
Dont smash aoview_monitor_parse input buffer
-rw-r--r-- | aoview/aoview.h | 2 | ||||
-rw-r--r-- | aoview/aoview_monitor.c | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/aoview/aoview.h b/aoview/aoview.h index 7807b2fa..5c118a11 100644 --- a/aoview/aoview.h +++ b/aoview/aoview.h @@ -124,7 +124,7 @@ gboolean aoview_monitor_connect(char *tty); gboolean -aoview_monitor_parse(char *line); +aoview_monitor_parse(const char *line); void aoview_monitor_reset(void); diff --git a/aoview/aoview_monitor.c b/aoview/aoview_monitor.c index f7f646ae..5810be5b 100644 --- a/aoview/aoview_monitor.c +++ b/aoview/aoview_monitor.c @@ -68,12 +68,17 @@ aoview_parse_pos(double *target, char *source) static struct aostate state; gboolean -aoview_monitor_parse(char *line) +aoview_monitor_parse(const char *input_line) { char *saveptr; char *words[64]; int nword; + char line_buf[8192], *line; + /* avoid smashing our input parameter */ + strncpy (line_buf, input_line, sizeof (line_buf)-1); + line_buf[sizeof(line_buf) - 1] = '\0'; + line = line_buf; for (nword = 0; nword < 64; nword++) { words[nword] = strtok_r(line, " \t\n", &saveptr); line = NULL; |