Fix month/year units in getdate
authorGreg Hudson <ghudson@mit.edu>
Sun, 6 Nov 2011 04:32:34 +0000 (04:32 +0000)
committerGreg Hudson <ghudson@mit.edu>
Sun, 6 Nov 2011 04:32:34 +0000 (04:32 +0000)
getdate strings like "1 month" or "next year" would fail some of the
time, depending on the value of stack garbage, because DSTcorrect()
doesn't set *error on success and RelativeMonth() doesn't initialize
error.  Make DSTcorrect() responsible for setting *error in all cases.

ticket: 7003
target_version: 1.10
tags: pullup

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25444 dc483132-0cff-0310-8789-dd5450dbe970

src/kadmin/cli/getdate.y

index 613bc609c25690871a3cf306853fd62bf81db37b..fc0a403e20596b96c0983c1ee6bb61a331591143 100644 (file)
@@ -631,6 +631,7 @@ DSTcorrect(time_t Start, time_t Future, int *error)
        return -1;
     }
     FutureDay = (tm->tm_hour + 1) % 24;
+    *error = 0;
     return (Future - Start) + (StartDay - FutureDay) * 60L * 60L;
 }
 
@@ -873,7 +874,7 @@ get_date(char *p)
     time_t             Start;
     time_t             tod;
     time_t             delta;
-    int                        error = 0;
+    int                        error;
 
     yyInput = p;
     if (now == NULL) {