[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Fixes for character encoding problems in atgen.c (0.6.0)
From: |
Hugo Haas |
Subject: |
[PATCH] Fixes for character encoding problems in atgen.c (0.6.0) |
Date: |
Sat, 13 Mar 2004 10:10:20 +0100 |
User-agent: |
Mutt/1.5.5.1+cvs20040105i |
Summary: the attached patch fixes some character encoding problems for
AT communications.
Hi.
Thinking more about the T610 issues I posted a patch for yesterday, I
realized that it was normal that AT+CSCS="ME" fails with UCS-2
encoding as ME wasn't encoded in UCS-2 in my minicom test.
Looking at atgen.c, I noticed that gnokii did the same mistake, as it
sets the memory type without checking what encoding is used. I also
noted that gnokii wasn't checking the encoding in ReplyReadPhonebook()
when receiving a phone number, and --getphonebook would give me:
1. Name: Foo Bar/H
Number: 004500...
Group id: 0
which would eventually lead to a segmentation fault as numbers aren't
supposed to be that long: GN_PHONEBOOK_NUMBER_MAX_LENGTH equals 49,
and a UCS-2 encoded number could be 50+ byte-long.
The attached patch fixes those problems by:
- adding character encoding code in at_memory_type_set().
- adding character decoding code for the phone number in
ReplyReadPhonebook().
As I noticed that there were several places where essentially the same
code was used to encode and decode strings, I factorized it in
at_get.c by adding two new functions at_encode() and at_decode().
The total is 52 insertions(+), 51 deletions(-), so the code didn't
get bigger. :-)
This makes my unicode option patch unnecessary. Well, some people
might be interested in using it, I guess.
Regards,
Hugo
--
Hugo Haas - http://larve.net/people/hugo/
gnokii-atgen-encoding-fix.diff
Description: Text document
signature.asc
Description: Digital signature
- [PATCH] Fixes for character encoding problems in atgen.c (0.6.0),
Hugo Haas <=