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

Commit 2e7bd47d authored by fionaxu's avatar fionaxu Committed by android-build-merger
Browse files

backport security fix: avoid set NITZ time to 2038 am: 6c2365a2

am: 4c10b30d

Change-Id: I73318ebba70279899920adf4dc164b8d14171159
parents f61e7e7a 4c10b30d
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;
@@ -1500,6 +1502,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!