Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 885d3b2c authored by fionaxu's avatar fionaxu Committed by Michael Bestas
Browse files

backport security fix: avoid set NITZ time to 2038

Bug: 29083635
Change-Id: I21c5f4147d8146f92b7e33f0967a179ae644a263
(cherry picked from commit 6c2365a2)
parent e54009e3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
    private static final int NITZ_UPDATE_DIFF_DEFAULT = 2000;
    private int mNitzUpdateDiff = SystemProperties.getInt("ro.nitz_update_diff",
            NITZ_UPDATE_DIFF_DEFAULT);
    /** Time stamp after 19 January 2038 is not supported under 32 bit */
    private static final int MAX_NITZ_YEAR = 2037;

    private boolean mSubscribeOnRuimReady = SystemProperties.getBoolean(
            "ro.cdma.subscribe_on_ruim_ready", false);
@@ -1357,6 +1359,10 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
            String[] nitzSubs = nitz.split("[/:,+-]");

            int year = 2000 + Integer.parseInt(nitzSubs[0]);
            if (year > MAX_NITZ_YEAR) {
              if (DBG) loge("NITZ year: " + year + " exceeds limit, skip NITZ time update");
              return;
            }
            c.set(Calendar.YEAR, year);

            // month is 0 based!
+6 −0
Original line number Diff line number Diff line
@@ -129,6 +129,8 @@ public class GsmServiceStateTracker extends ServiceStateTracker {

    /** Boolean is true is setTimeFromNITZString was called */
    private boolean mNitzUpdatedTime = false;
    /** Time stamp after 19 January 2038 is not supported under 32 bit */
    private static final int MAX_NITZ_YEAR = 2037;

    String mSavedTimeZone;
    long mSavedTime;
@@ -1598,6 +1600,10 @@ public class GsmServiceStateTracker extends ServiceStateTracker {
            String[] nitzSubs = nitz.split("[/:,+-]");

            int year = 2000 + Integer.parseInt(nitzSubs[0]);
            if (year > MAX_NITZ_YEAR) {
              if (DBG) loge("NITZ year: " + year + " exceeds limit, skip NITZ time update");
              return;
            }
            c.set(Calendar.YEAR, year);

            // month is 0 based!