[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-15
From: |
Pawel Kot |
Subject: |
[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-151-g299ace3 |
Date: |
Sun, 30 Jan 2011 11:19:33 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "libgnokii and core programs".
The branch, master has been updated
via 299ace3691a92a4fbc7341c2623e928fd59f8660 (commit)
from f338a215bb7b072a590976012633782a952f1912 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=299ace3691a92a4fbc7341c2623e928fd59f8660
commit 299ace3691a92a4fbc7341c2623e928fd59f8660
Author: Pawel Kot <address@hidden>
Date: Sun Jan 30 11:54:16 2011 +0100
Avoid overruns in phonet link driver
Fix the problem reported by Daniele Forsi when running --getringtone with
some big ringtone file
PHONET: Message buffer overrun - resetting (message length: 1896, max:
1010)
Make the incoming message buffer dynamic with initial size of
PHONET_FRAME_MAX_LENGTH and extended whenever larger frame comes in.
diff --git a/ChangeLog b/ChangeLog
index 2532b7f..e140ef8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
used driver in runtime (PaweÅ Kot)
o GSM number type is rather mask than define; use it as such
when parsing the input (PaweÅ Kot)
+ o avoid overruns in phonet (PaweÅ Kot)
* nk6510 driver updates
o fix calendar handling issues (few off-by-ones) (PaweÅ Kot)
o implement deletecalendarnote for series40 3rd+ Ed (PaweÅ Kot)
diff --git a/common/links/atbus.c b/common/links/atbus.c
index 9265eb0..20fae45 100644
--- a/common/links/atbus.c
+++ b/common/links/atbus.c
@@ -1,7 +1,5 @@
/*
- $Id$
-
G N O K I I
A Linux/Unix toolset and driver for the mobile phones.
@@ -24,7 +22,7 @@
Copyright (C) 2001-2002 Manfred Jonsson <address@hidden>
Copyright (C) 2001-2003 Ladis Michl
- Copyright (C) 2001-2004 Pawel Kot
+ Copyright (C) 2001-2011 Pawel Kot
Copyright (C) 2002-2004 BORBELY Zoltan
Copyright (C) 2002 Pavel Machek
@@ -300,6 +298,7 @@ gn_error atbus_initialise(int mode, struct gn_statemachine
*state)
state->link.loop = &atbus_loop;
state->link.send_message = &at_send_message;
state->link.reset = &atbus_reset;
+ state->link.cleanup = NULL;
AT_BUSINST(state) = businst;
atbus_reset(state);
diff --git a/common/links/cbus.c b/common/links/cbus.c
index df0777b..ef2d443 100644
--- a/common/links/cbus.c
+++ b/common/links/cbus.c
@@ -23,7 +23,7 @@
Copyright (C) 2001 Pavel Machek <address@hidden>
Copyright (C) 2001-2003 Ladislav Michl <address@hidden>
Copyright (C) 2001 Manfred Jonsson
- Copyright (C) 2001-2004 Pawel Kot
+ Copyright (C) 2001-2011 Pawel Kot
Copyright (C) 2002-2003 BORBELY Zoltan
*/
@@ -330,6 +330,7 @@ gn_error cbus_initialise(struct gn_statemachine *state)
state->link.loop = &cbus_loop;
state->link.send_message = &cbus_send_message;
state->link.reset = NULL;
+ state->link.cleanup = NULL;
CBUSINST(state) = businst;
if (state->config.connection_type == GN_CT_Serial) {
diff --git a/common/links/fbus-3110.c b/common/links/fbus-3110.c
index 7dfbc60..60fe700 100644
--- a/common/links/fbus-3110.c
+++ b/common/links/fbus-3110.c
@@ -1,7 +1,5 @@
/*
- $Id$
-
G N O K I I
A Linux/Unix toolset and driver for the mobile phones.
@@ -23,7 +21,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Copyright (C) 1999-2000 Hugh Blemings & Pavel Janik ml.
- Copyright (C) 2001-2004 Pawel Kot
+ Copyright (C) 2001-2011 Pawel Kot
Copyright (C) 2002 Ladis Michl
Copyright (C) 2002-2003 BORBELY Zoltan
Copyright (C) 2003-2004 Osma Suominen
@@ -358,6 +356,7 @@ gn_error fb3110_initialise(struct gn_statemachine *state)
state->link.loop = &fb3110_loop;
state->link.send_message = &fb3110_message_send;
state->link.reset = &fb3110_reset;
+ state->link.cleanup = NULL;
/* Check for a valid init length */
if (state->config.init_length == 0)
diff --git a/common/links/fbus-phonet.c b/common/links/fbus-phonet.c
index fa33746..2814bff 100644
--- a/common/links/fbus-phonet.c
+++ b/common/links/fbus-phonet.c
@@ -1,7 +1,5 @@
/*
- $Id$
-
G N O K I I
A Linux/Unix toolset and driver for the mobile phones.
@@ -24,7 +22,7 @@
Copyright (C) 1999-2000 Hugh Blemings & Pavel Janik ml.
Copyright (C) 2000-2001 Chris Kemp
- Copyright (C) 2001-2004 Pawel Kot
+ Copyright (C) 2001-2011 Pawel Kot
Copyright (C) 2001 Manfred Jonsson, Martin Jancar
Copyright (C) 2002 Ladis Michl
Copyright (C) 2002-2003 BORBELY Zoltan
@@ -63,6 +61,24 @@ static gn_error phonet_send_message(unsigned int
messagesize, unsigned char mess
/*--------------------------------------------*/
+static int verify_max_message_len(int len, char **message_buffer)
+{
+ static int max_message_len = 0;
+
+ if (len > max_message_len) {
+ dprintf("overrun: %d %d\n", len, max_message_len);
+ *message_buffer = realloc(*message_buffer, len + 1);
+ max_message_len = len + 1;
+ }
+ if (*message_buffer)
+ return max_message_len;
+ else
+ return 0;
+}
+
+
+/*--------------------------------------------*/
+
static bool phonet_open(struct gn_statemachine *state)
{
int result, i, n, total = 0;
@@ -168,32 +184,23 @@ static void phonet_rx_statemachine(unsigned char rx_byte,
struct gn_statemachine
i->message_length = i->message_length + rx_byte;
i->state = FBUS_RX_GetMessage;
i->buffer_count = 0;
- if (i->message_length > PHONET_FRAME_MAX_LENGTH) {
- dprintf("PHONET: Message buffer overrun - resetting
(message length: %d, max: %d)\n", i->message_length, PHONET_FRAME_MAX_LENGTH);
- }
break;
case FBUS_RX_GetMessage:
- if (i->message_length > PHONET_FRAME_MAX_LENGTH) {
- /* Ignore this frame that would overflow the buffer */
- if (i->buffer_count % 16 == 0)
- dprintf("\n");
- dprintf("%02x ", rx_byte);
- i->buffer_count++;
-
- if (i->buffer_count == i->message_length) {
- dprintf("\n");
- i->state = FBUS_RX_Sync;
- }
- } else {
- i->message_buffer[i->buffer_count] = rx_byte;
- i->buffer_count++;
-
- /* Is that it? */
- if (i->buffer_count == i->message_length) {
- sm_incoming_function(i->message_type,
i->message_buffer, i->message_length, state);
- i->state = FBUS_RX_Sync;
- }
+ if (!verify_max_message_len(i->message_length,
&(i->message_buffer))) {
+ dprintf("PHONET: Failed to allocate memory for larger
buffer\n");
+ dprintf("PHONET: Message buffer overrun - resetting
(message length: %d, max: %d)\n", i->message_length, PHONET_FRAME_MAX_LENGTH);
+ dprintf("PHONET: Resetting\n");
+ i->state = FBUS_RX_Sync;
+ break;
+ }
+ i->message_buffer[i->buffer_count] = rx_byte;
+ i->buffer_count++;
+
+ /* Is that it? */
+ if (i->buffer_count == i->message_length) {
+ sm_incoming_function(i->message_type,
i->message_buffer, i->message_length, state);
+ i->state = FBUS_RX_Sync;
}
break;
@@ -231,7 +238,6 @@ static gn_error phonet_loop(struct timeval *timeout, struct
gn_statemachine *sta
}
/* Main function to send an fbus message */
-
static gn_error phonet_send_message(unsigned int messagesize, unsigned char
messagetype, unsigned char *message, struct gn_statemachine *state)
{
@@ -303,6 +309,12 @@ static void phonet_reset(struct gn_statemachine *state)
FBUSINST(state)->buffer_count = 0;
}
+static void phonet_cleanup(struct gn_statemachine *state)
+{
+ free(FBUSINST(state)->message_buffer);
+ FBUSINST(state)->message_buffer = NULL;
+}
+
/* Initialise variables and start the link */
gn_error phonet_initialise(struct gn_statemachine *state)
{
@@ -319,6 +331,9 @@ gn_error phonet_initialise(struct gn_statemachine *state)
if ((FBUSINST(state) = calloc(1, sizeof(phonet_incoming_message))) ==
NULL)
return GN_ERR_MEMORYFULL;
+ if (!verify_max_message_len(PHONET_FRAME_MAX_LENGTH,
&(FBUSINST(state)->message_buffer)))
+ return GN_ERR_MEMORYFULL;
+
switch (state->config.connection_type) {
case GN_CT_Infrared:
case GN_CT_Irda:
diff --git a/common/links/fbus.c b/common/links/fbus.c
index ebd0664..8bc5983 100644
--- a/common/links/fbus.c
+++ b/common/links/fbus.c
@@ -1,7 +1,5 @@
/*
- $Id$
-
G N O K I I
A Linux/Unix toolset and driver for the mobile phones.
@@ -677,6 +675,7 @@ gn_error fbus_initialise(int attempt, struct
gn_statemachine *state)
state->link.loop = &fbus_loop;
state->link.send_message = &fbus_send_message;
state->link.reset = &fbus_reset;
+ state->link.cleanup = NULL;
/* Check for a valid init length */
if (state->config.init_length == 0)
diff --git a/common/links/gnbus.c b/common/links/gnbus.c
index 7d03e36..502cd76 100644
--- a/common/links/gnbus.c
+++ b/common/links/gnbus.c
@@ -1,7 +1,5 @@
/*
- $Id$
-
G N O K I I
A Linux/Unix toolset and driver for Nokia mobile phones.
@@ -290,6 +288,7 @@ gn_error gnbus_initialise(struct gn_statemachine *state)
state->link.loop = &gnbus_loop;
state->link.send_message = &gnbus_send_message;
state->link.reset = &gnbus_reset;
+ state->link.cleanup = NULL;
/* Start up the link */
if ((GNBUSINST(state) = calloc(1, sizeof(gnbus_link))) == NULL)
diff --git a/common/links/m2bus.c b/common/links/m2bus.c
index 40dcee4..e41ac1d 100644
--- a/common/links/m2bus.c
+++ b/common/links/m2bus.c
@@ -1,7 +1,5 @@
/*
- $Id$
-
G N O K I I
A Linux/Unix toolset and driver for the mobile phones.
@@ -24,7 +22,8 @@
Copyright (C) 2000 Hugh Blemings & Pavel Janik ml.
Copyright (C) 2000 Chris Kemp
- Copyright (C) 2002-2004 BORBELY Zoltan, Pawel Kot
+ Copyright (C) 2002-2004 BORBELY Zoltan
+ Copyright (C) 2002-2011 Pawel Kot
Copyright (C) 2002 Ladis Michl
This file provides an API for accessing functions via m2bus.
@@ -466,6 +465,7 @@ gn_error m2bus_initialise(struct gn_statemachine *state)
state->link.loop = &m2bus_loop;
state->link.send_message = &m2bus_send_message;
state->link.reset = &m2bus_reset;
+ state->link.cleanup = NULL;
/* Start up the link */
if ((M2BUSINST(state) = calloc(1, sizeof(m2bus_link))) == NULL)
diff --git a/common/links/utils.c b/common/links/utils.c
index 5bbb02c..27c1ab3 100644
--- a/common/links/utils.c
+++ b/common/links/utils.c
@@ -1,7 +1,5 @@
/*
- $Id$
-
G N O K I I
A Linux/Unix toolset and driver for the mobile phones.
@@ -24,7 +22,7 @@
Copyright (C) 2001-2002 Pavel Machek, Ladis Michl, Manfred Jonsson
<address@hidden>
Copyright (C) 2001 Chris Kemp
- Copyright (C) 2001-2004 Pawel Kot
+ Copyright (C) 2001-2011 Pawel Kot
Copyright (C) 2002-2004 BORBELY Zoltan
*/
@@ -49,6 +47,8 @@ gn_error link_terminate(struct gn_statemachine *state)
return GN_ERR_FAILED;
/* device_close(&(state->Device)); */
+ if (state->link.cleanup)
+ state->link.cleanup(state);
if (state->link.link_instance) {
free(state->link.link_instance);
state->link.link_instance = NULL;
diff --git a/include/gnokii/data.h b/include/gnokii/data.h
index 633a797..a271361 100644
--- a/include/gnokii/data.h
+++ b/include/gnokii/data.h
@@ -1,7 +1,5 @@
/*
- $Id$
-
G N O K I I
A Linux/Unix toolset and driver for the mobile phones.
@@ -23,7 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Copyright (C) 1999-2000 Hugh Blemings & Pavel Janík ml.
- Copyright (C) 2002-2004 BORBELY Zoltan, Pawel Kot
+ Copyright (C) 2002-2004 BORBELY Zoltan
+ Copyright (C) 2002-2011 Pawel Kot
Copyright (C) 2002 Ladis Michl, Markus Plail, Pavel Machek, Chris Kemp
*/
@@ -154,6 +153,7 @@ typedef struct {
struct gn_statemachine *state);
void *link_instance;
void (*reset)(struct gn_statemachine *state);
+ void (*cleanup)(struct gn_statemachine *state);
} gn_link;
typedef struct {
diff --git a/include/links/fbus-phonet.h b/include/links/fbus-phonet.h
index 44f9171..33e06b3 100644
--- a/include/links/fbus-phonet.h
+++ b/include/links/fbus-phonet.h
@@ -1,7 +1,5 @@
/*
- $Id$
-
G N O K I I
A Linux/Unix toolset and driver for the mobile phones.
@@ -24,7 +22,7 @@
Copyright (C) 1999-2000 Hugh Blemings & Pavel Janík ml.
Copyright (C) 2000 Chris Kemp
- Copyright (C) 2001-2004 Pawel Kot
+ Copyright (C) 2001-2011 Pawel Kot
Copyright (C) 2002 BORBELY Zoltan, Ladis Michl
This file provides an API for accessing functions via fbus over irda.
@@ -63,7 +61,7 @@ typedef struct {
int message_destination;
int message_type;
int message_length;
- char message_buffer[PHONET_FRAME_MAX_LENGTH];
+ char *message_buffer;
} phonet_incoming_message;
#endif /* #ifndef _gnokii_links_fbus_phonet_h */
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 1 +
common/links/atbus.c | 5 +--
common/links/cbus.c | 3 +-
common/links/fbus-3110.c | 5 +--
common/links/fbus-phonet.c | 69 ++++++++++++++++++++++++++-----------------
common/links/fbus.c | 3 +-
common/links/gnbus.c | 3 +-
common/links/m2bus.c | 6 ++--
common/links/utils.c | 6 ++--
include/gnokii/data.h | 6 ++--
include/links/fbus-phonet.h | 6 +--
11 files changed, 62 insertions(+), 51 deletions(-)
hooks/post-receive
--
libgnokii and core programs
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-151-g299ace3,
Pawel Kot <=