Warning: Can't synchronize with repository "(default)" (No changeset 96d22ec3fa3ef6de3ea8dc0d7d398adc9aa071cf in the repository). Look in the Trac log for more information.

Ticket #110 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

"string index out of range" in comparePhoneNumber

Reported by: timo.lindfors@… Owned by: anonymous
Priority: major Milestone:
Component: zhone/general Version:
Keywords: Cc:

Description

Version: 0-git20080809-4

After suspend zhone generates the following backtrace:

Traceback (most recent call last):

File "/var/lib/python-support/python2.5/dbus/connection.py", line 578, in msg_reply_handler

reply_handler(*message.get_args_list(get_args_opts))

File "/usr/bin/zhone", line 396, in cbMessagebookReply

self.updateList()

File "/usr/bin/zhone", line 453, in updateList

main_text = self.main.groupscontacts?.tryNumberToName( self.current[i][2] )

File "/usr/bin/zhone", line 677, in tryNumberToName

if self.comparePhoneNumber(self.phonebook[i][2], number):

File "/usr/bin/zhone", line 670, in comparePhoneNumber

if number1[0] == number2[0] == '+':

IndexError?: string index out of range

Change History

comment:1 Changed 5 years ago by timo.lindfors@…

Here's more info (phone number replaced with X's):

debian-gta02:~# DISPLAY=:0 python -m pdb /usr/bin/zhone
--Return--
> /usr/lib/python2.5/encodings/__init__.py(68)normalize_encoding()->'utf8'
-> return '_'.join(encoding.translate(_norm_encoding_map).split())
(Pdb) cont
Traceback (most recent call last):
  File "/var/lib/python-support/python2.5/dbus/connection.py", line 578, in msg_reply_handler
    reply_handler(*message.get_args_list(**get_args_opts))
  File "/usr/bin/zhone", line 396, in cbMessagebookReply
    self.updateList()
  File "/usr/bin/zhone", line 453, in updateList
    main_text = self.main.groups["contacts"].tryNumberToName( self.current[i][2] )
  File "/usr/bin/zhone", line 677, in tryNumberToName
    if self.comparePhoneNumber(self.phonebook[i][2], number):
  File "/usr/bin/zhone", line 670, in comparePhoneNumber
    if number1[0] == number2[0] == '+':
IndexError: string index out of range

The program finished and will be restarted
--Return--
> /usr/lib/python2.5/codecs.py(366)__init__()->None
-> self.linebuffer = None
(Pdb) import pdb
(Pdb) pdb.pm()
> /usr/bin/zhone(670)comparePhoneNumber()
-> if number1[0] == number2[0] == '+':
(Pdb) p number1
u'+XXXXXXXXXXXX'
(Pdb) p number2
u''
(Pdb)

Btw, can you please give me an account to this bug tracker? I have having to type my email address all the time without actually getting any email :-)

comment:2 Changed 5 years ago by lindi

  • Priority changed from minor to major

It seems I get this also when I click the SMS icon in the main menu. I then only see background image with no way to read SMS or return to main menu. Raising priority.

comment:3 Changed 5 years ago by anonymous<b0ef> any reason the kernel does not load hci_usb and ohci-hcd and I have to load them everytime I boot? <b0ef> right, maybe it doesn't load them cause the chip is off;) mail@…

  • Owner changed from mickey to mail@…

My bad. I didn’t expect to receive empty strings there. I’ll create a patch soonish, but until then: Do you know where the empty number comes from?

comment:4 Changed 5 years ago by lindi

I debugged some more:

(Pdb) up
> /usr/bin/zhone(677)tryNumberToName()
-> if self.comparePhoneNumber(self.phonebook[i][2], number):
(Pdb) p number
dbus.String(u'Verkkokaupp')

Verkkokauppa is a shop that sent me SMS recently. Why is its name in a variable used for phone numbers? Going further up I see

(Pdb) up
> /usr/bin/zhone(453)updateList()
-> main_text = self.main.groups["contacts"].tryNumberToName( self.current[i][2] )
(Pdb) p self.current[i][2]
dbus.String(u'Verkkokaupp')
(Pdb) p self.messagebook
dbus.Array([dbus.Struct((dbus.Int32(1), dbus.String(u'read'), dbus.String(u'+[removed valid number]'), dbus.String(u'[removed lots of hex]')), signature=None), dbus.Struct((dbus.Int32(2), dbus.String(u'read'), dbus.String(u'+[removed valid number]'), dbus.String(u'[removed lots of hex]')), signature=None), dbus.Struct((dbus.Int32(3), dbus.String(u'read'), dbus.String(u'Verkkokaupp'), dbus.String(u'Verkkokauppa.com kiitt\xe4\xe4 tilauksestanne. Tilaustanne [removed], k\xe4sittelee Petri Hyry, puh. 010 309 5555, myynti@verkkokauppa.com')), signature=None), dbus.Struct((dbus.Int32(4), dbus.String(u'read'), dbus.String(u'+[removed valid number]'), dbus.String(u'[removed latin1 text]')), signature=None)], signature=dbus.Signature('(isss)'))

Why does the messagebook contain a string instead of a number as sender?

comment:5 Changed 5 years ago by mail@…

  • Owner changed from mail@… to anonymous
  • Status changed from new to assigned

Well, I have heared that there is a way of sending text as the sender SMS.

comment:6 Changed 5 years ago by lindi

Here's a fix:

--- /usr/bin/zhone.orig 2008-09-01 09:10:44.000000000 +0000 +++ /usr/bin/zhone 2008-09-01 09:11:20.000000000 +0000 @@ -667,7 +667,7 @@

number1 = filter (lambda c: c.isdigit() or c == '+', number1) number2 = filter (lambda c: c.isdigit() or c == '+', number2)

  • if number1[0] == number2[0] == '+':

+ if number1.startswith('+') and number2.startswith('+'):

return number1 == number2

else:

return number1[-7:] == number2[-7:]

comment:7 Changed 5 years ago by lindi

Here's the fix, this time without wikiformating :-)

--- /usr/bin/zhone.orig 2008-09-01 09:10:44.000000000 +0000
+++ /usr/bin/zhone      2008-09-01 09:11:20.000000000 +0000
@@ -667,7 +667,7 @@
         number1 = filter (lambda c: c.isdigit() or c == '+', number1)
         number2 = filter (lambda c: c.isdigit() or c == '+', number2)

-        if number1[0] == number2[0] == '+':
+        if number1.startswith('+') and number2.startswith('+'):
             return number1 == number2
         else:
             return number1[-7:] == number2[-7:]

comment:8 Changed 5 years ago by mail@…

Well, not perfect, as this would mean that two strings are always equal. Instead, if no numbers are left after the filter (or only very few, say less than three), then we should just compare the original strings.

comment:10 Changed 5 years ago by mickey

  • Status changed from assigned to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.