Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ] Fix incorrect use of atoi in maemo6
@ 2011-10-27 10:42 Dmitriy Paliy
  2011-10-27 13:22 ` Anderson Lizardo
  2011-10-28 11:00 ` Johan Hedberg
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitriy Paliy @ 2011-10-27 10:42 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Dmitriy Paliy

Use of atoi is incorrect and unsafe in maemo6 telephony and replaced
by g_ascii_digit_value.
---
 audio/telephony-maemo6.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/audio/telephony-maemo6.c b/audio/telephony-maemo6.c
index 5df3235..a546f44 100644
--- a/audio/telephony-maemo6.c
+++ b/audio/telephony-maemo6.c
@@ -823,7 +823,9 @@ static int tonegen_startevent(char tone)
 		event_tone = DTMF_D;
 		break;
 	default:
-		event_tone = atoi(&tone);
+		event_tone = g_ascii_digit_value(tone);
+		if (event_tone < 0)
+			return -EINVAL;
 	}
 
 	ret = send_method_call(TONEGEN_BUS_NAME, TONEGEN_PATH,
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH BlueZ] Fix incorrect use of atoi in maemo6
  2011-10-27 10:42 [PATCH BlueZ] Fix incorrect use of atoi in maemo6 Dmitriy Paliy
@ 2011-10-27 13:22 ` Anderson Lizardo
  2011-10-27 13:33   ` Dmitriy Paliy
  2011-10-28 11:00 ` Johan Hedberg
  1 sibling, 1 reply; 4+ messages in thread
From: Anderson Lizardo @ 2011-10-27 13:22 UTC (permalink / raw)
  To: Dmitriy Paliy; +Cc: linux-bluetooth

Hi Dmitriy,

On Thu, Oct 27, 2011 at 6:42 AM, Dmitriy Paliy <dmitriy.paliy@nokia.com> wrote:
> Use of atoi is incorrect and unsafe in maemo6 telephony and replaced
> by g_ascii_digit_value.

There are lots of atoi() calls in other parts of BlueZ. Are they safe?
What is exactly unsafe in using atoi()?

Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH BlueZ] Fix incorrect use of atoi in maemo6
  2011-10-27 13:22 ` Anderson Lizardo
@ 2011-10-27 13:33   ` Dmitriy Paliy
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitriy Paliy @ 2011-10-27 13:33 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: Dmitriy Paliy, linux-bluetooth

Hi,

> There are lots of atoi() calls in other parts of BlueZ. Are they safe?

Yes

> What is exactly unsafe in using atoi()?

The string should be null-terminated, which is not in this case, since
it is just a char. It was my mistake.

Br,
Dmitriy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH BlueZ] Fix incorrect use of atoi in maemo6
  2011-10-27 10:42 [PATCH BlueZ] Fix incorrect use of atoi in maemo6 Dmitriy Paliy
  2011-10-27 13:22 ` Anderson Lizardo
@ 2011-10-28 11:00 ` Johan Hedberg
  1 sibling, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2011-10-28 11:00 UTC (permalink / raw)
  To: Dmitriy Paliy; +Cc: linux-bluetooth

Hi Dmitriy,

On Thu, Oct 27, 2011, Dmitriy Paliy wrote:
> Use of atoi is incorrect and unsafe in maemo6 telephony and replaced
> by g_ascii_digit_value.
> ---
>  audio/telephony-maemo6.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/audio/telephony-maemo6.c b/audio/telephony-maemo6.c
> index 5df3235..a546f44 100644
> --- a/audio/telephony-maemo6.c
> +++ b/audio/telephony-maemo6.c
> @@ -823,7 +823,9 @@ static int tonegen_startevent(char tone)
>  		event_tone = DTMF_D;
>  		break;
>  	default:
> -		event_tone = atoi(&tone);
> +		event_tone = g_ascii_digit_value(tone);
> +		if (event_tone < 0)
> +			return -EINVAL;
>  	}
>  
>  	ret = send_method_call(TONEGEN_BUS_NAME, TONEGEN_PATH,

Doesn't compile:

udio/telephony-maemo6.c: In function ‘tonegen_startevent’:
audio/telephony-maemo6.c:827:3: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]


Please fix and resend.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-10-28 11:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-27 10:42 [PATCH BlueZ] Fix incorrect use of atoi in maemo6 Dmitriy Paliy
2011-10-27 13:22 ` Anderson Lizardo
2011-10-27 13:33   ` Dmitriy Paliy
2011-10-28 11:00 ` Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox