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

Commit 6c2365a2 authored by fionaxu's avatar fionaxu
Browse files

backport security fix: avoid set NITZ time to 2038

Bug: 29083635
Change-Id: I21c5f4147d8146f92b7e33f0967a179ae644a263
parent 98f7080e
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 mCdmaRoaming = false;
    private int mRoamingIndicator;
@@ -1324,6 +1326,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
@@ -127,6 +127,8 @@ final 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;
@@ -1502,6 +1504,10 @@ final 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!