[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, master, updated. milestone4-368-g700ab82
Daniel Willmann
daniel at totalueberwachung.de
Mon Feb 2 18:51:55 UTC 2009
The following commit has been merged in the master branch:
commit 29306c804c8bbf9e5e9733650694b13ad70e86d8
Author: Daniel Willmann <daniel at totalueberwachung.de>
Date: Mon Jan 12 17:10:50 2009 +0100
ogsmd: [SMS] Don't fail when service center timestamps are invalid
If parsing the scts field fails the date is substituted for a dummy
value and the error property is marked accordingly.
diff --git a/framework/subsystems/ogsmd/gsm/convert.py b/framework/subsystems/ogsmd/gsm/convert.py
index 11179da..223a53d 100644
--- a/framework/subsystems/ogsmd/gsm/convert.py
+++ b/framework/subsystems/ogsmd/gsm/convert.py
@@ -66,15 +66,20 @@ def bcd_encode(number):
#=========================================================================#
def decodePDUTime(bs):
#=========================================================================#
- bs = [((n & 0xf) * 10) + (n >> 4) for n in bs]
- if bs[0] >= 90: # I don't know if this is the right cut-off point...
- year = 1900 + bs[0]
+ [year, month, day, hour, minute, second, timezone] = \
+ [((n & 0xf) * 10) + (n >> 4) for n in bs]
+ if year >= 90: # I don't know if this is the right cut-off point...
+ year += 1900
else:
- year = 2000 + bs[0]
- timezone = bs[6]
+ year += 2000
sign = (timezone >> 7) * 2 - 1
zone = (timezone & 0x7f) / -4. * sign
- return ( datetime(year, bs[1], bs[2], bs[3], bs[4], bs[5]), zone )
+
+ # Invalid dates will generate a ValueError here which needs catching in
+ # higher levels
+ result = datetime(year, month, day, hour, minute, second)
+
+ return ( result, zone )
#=========================================================================#
def encodePDUTime(timeobj):
diff --git a/framework/subsystems/ogsmd/gsm/sms.py b/framework/subsystems/ogsmd/gsm/sms.py
index ac09b9b..43053b9 100644
--- a/framework/subsystems/ogsmd/gsm/sms.py
+++ b/framework/subsystems/ogsmd/gsm/sms.py
@@ -160,7 +160,13 @@ class SMS(object):
if sms.type == "sms-deliver" or sms.type == "sms-submit-report":
# SCTS - Service Centre Time Stamp
- sms.scts = decodePDUTime( bytes[offset:offset+7] )
+ try:
+ sms.scts = decodePDUTime( bytes[offset:offset+7] )
+ except ValueError, e:
+ sms.error.append("Service Center Timestamp invalid")
+ from datetime import datetime
+ sms.scts = (datetime(1980, 01, 01, 00, 00, 00), 0)
+
offset += 7
elif sms.type == "sms-submit":
# VP - Validity Period FIXME
@@ -170,7 +176,13 @@ class SMS(object):
offset += 1
elif sms.pdu_vpf == 3:
# Absolute
- sms.vp = decodePDUTime( bytes[offset:offset+7] )
+ try:
+ sms.vp = decodePDUTime( bytes[offset:offset+7] )
+ except ValueError, e:
+ sms.error.append("Validity Period invalid")
+ from datetime import datetime
+ sms.vp = (datetime(1980, 01, 01, 00, 00, 00), 0)
+
offset += 7
if sms.type == "sms-submit-report" and not sms.pdu_udli:
--
FSO frameworkd Debian packaging
More information about the pkg-fso-commits
mailing list