util: Make sure to handle special empty strings
authorDenis Kenzior <denkenz@gmail.com>
Thu, 16 Aug 2012 05:47:59 +0000 (00:47 -0500)
committerDenis Kenzior <denkenz@gmail.com>
Thu, 16 Aug 2012 05:47:59 +0000 (00:47 -0500)
Some SIMs contain an EFspn with the contents all set to 'filler'
characters, e.g. 0xFF.  We mistakenly do not handle these strings
correctly.

Aug  8 11:40:00 mx31tt01 daemon.info ofonod[622]: Aux: >
AT+CRSM=176,28486,0,0,17\r
Aug  8 11:40:00 mx31tt01 daemon.info ofonod[622]: Aux: < \r\n+CRSM:
144,0,FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\r\n\r\nOK\r\n
Aug  8 11:40:00 mx31tt01 daemon.debug ofonod[622]:
drivers/atmodem/sim.c:at_crsm_read_cb() crsm_read_cb: 90, 00, 17
Aug  8 11:40:00 mx31tt01 daemon.debug ofonod[622]:
src/simfs.c:sim_fs_op_read_block_cb() bufoff: 0, dataoff: 0, tocopy: 17
Aug  8 11:40:00 mx31tt01 daemon.err ofonod[622]: EFspn read
successfully, but couldn't parse

src/util.c

index 057ae1c..df9d4f0 100644 (file)
@@ -1276,6 +1276,12 @@ char *sim_string_to_utf8(const unsigned char *buffer, int length)
                offset = 4;
                break;
 
+       case 0xff: /* Special case of empty string */
+               num_chars = 0;
+               ucs2_offset = 0;
+               offset = 0;
+               break;
+
        default:
                return NULL;
        }