]> granicus.if.org Git - sudo/commitdiff
Warn if the time stamp in the I/O log file does not fit in time_t.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 14 Dec 2013 15:30:37 +0000 (08:30 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 14 Dec 2013 15:30:37 +0000 (08:30 -0700)
Warn if the info line is not well-formed instead of silently ignoring
it.

plugins/sudoers/sudoreplay.c

index f2c4147eb93d787cdeca0eb95252b9782a3e91ac..3b28633c03fa9342978b67fc606b49cce366e931 100644 (file)
@@ -822,6 +822,7 @@ parse_logfile(char *logfile)
     if (getline(&buf, &bufsize, fp) == -1 ||
        getline(&li->cwd, &cwdsize, fp) == -1 ||
        getline(&li->cmd, &cmdsize, fp) == -1) {
+       warning(U_("%s: invalid log file"), logfile);
        goto bad;
     }
 
@@ -838,32 +839,40 @@ parse_logfile(char *logfile)
     cp = buf;
 
     /* timestamp */
-    if ((ep = strchr(cp, ':')) == NULL)
+    if ((ep = strchr(cp, ':')) == NULL) {
+       warning(U_("%s: time stamp field is missing"), logfile);
        goto bad;
+    }
     *ep = '\0';
-    li->tstamp = strtonum(cp, LLONG_MIN, LLONG_MAX, &errstr);
+    li->tstamp = sizeof(time_t) == 4 ? strtonum(cp, INT_MIN, INT_MAX, &errstr) :
+       strtonum(cp, LLONG_MIN, LLONG_MAX, &errstr);
     if (errstr != NULL) {
-       sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
-           "%s: timestamp %s: %s", logfile, cp, errstr);
+       warning(U_("%s: time stamp %s: %s"), logfile, cp, errstr);
        goto bad;
     }
 
     /* user */
     cp = ep + 1;
-    if ((ep = strchr(cp, ':')) == NULL)
+    if ((ep = strchr(cp, ':')) == NULL) {
+       warning(U_("%s: user field is missing"), logfile);
        goto bad;
+    }
     li->user = estrndup(cp, (size_t)(ep - cp));
 
     /* runas user */
     cp = ep + 1;
-    if ((ep = strchr(cp, ':')) == NULL)
+    if ((ep = strchr(cp, ':')) == NULL) {
+       warning(U_("%s: runas user field is missing"), logfile);
        goto bad;
+    }
     li->runas_user = estrndup(cp, (size_t)(ep - cp));
 
     /* runas group */
     cp = ep + 1;
-    if ((ep = strchr(cp, ':')) == NULL)
+    if ((ep = strchr(cp, ':')) == NULL) {
+       warning(U_("%s: runas group field is missing"), logfile);
        goto bad;
+    }
     if (cp != ep)
        li->runas_group = estrndup(cp, (size_t)(ep - cp));