summaryrefslogtreecommitdiffstats
path: root/gatchat
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2011-08-09 20:00:58 -0700
committerMarcel Holtmann <marcel@holtmann.org>2011-08-09 20:00:58 -0700
commite266a5e220cfbb42fd3df7584415ed09cca5a035 (patch)
tree8c51d16d2029420c3bb4d91687cc95c954fa1d37 /gatchat
parent4dc66b9cb0ee809c1dd4c66640878a232aacf22d (diff)
downloadofono-e266a5e220cfbb42fd3df7584415ed09cca5a035.tar.bz2
gatchat: Fix marker handling within HDLC support
Diffstat (limited to 'gatchat')
-rw-r--r--gatchat/gathdlc.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/gatchat/gathdlc.c b/gatchat/gathdlc.c
index f50c1f5c..3c207dce 100644
--- a/gatchat/gathdlc.c
+++ b/gatchat/gathdlc.c
@@ -89,15 +89,15 @@ static inline void hdlc_record(GAtHDLC *hdlc, gboolean in,
unsigned char id;
int err;
- if (len == 0)
- return;
-
g_at_util_debug_hexdump(in, data, length,
hdlc->debugf, hdlc->debug_data);
if (hdlc->record_fd < 0)
return;
+ if (length == 0)
+ return;
+
gettimeofday(&now, NULL);
ts = htonl(now.tv_sec & 0xffffffff);
@@ -562,12 +562,19 @@ gboolean g_at_hdlc_send(GAtHDLC *hdlc, const unsigned char *data, gsize size)
if (hdlc->start_frame_marker == TRUE) {
/* Protocol requires 0x7e as start marker */
+ if (pos + 1 > avail)
+ return FALSE;
+
*buf++ = HDLC_FLAG;
pos++;
+
+ if (pos == wrap)
+ buf = ring_buffer_write_ptr(write_buffer, pos);
} else if (hdlc->wakeup_sent == FALSE) {
/* Write an initial 0x7e as wakeup character */
*buf++ = HDLC_FLAG;
pos++;
+
hdlc->wakeup_sent = TRUE;
}