34 lines
		
	
	
		
			995 B
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			995 B
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From 3a5bfc32357bd6bf27bde41a599ce797be221420 Mon Sep 17 00:00:00 2001
 | |
| From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= <opohorel@redhat.com>
 | |
| Date: Mon, 30 Jun 2025 15:23:26 +0200
 | |
| Subject: [PATCH] Reject past dates when using -t option
 | |
| 
 | |
| -t option was missing validation to reject past dates, unlike the
 | |
| regular time parsing.
 | |
| 
 | |
| Add the same past date validation used by parsetime() to the posixtime()
 | |
| code path to ensure consistent behavior when parsing time.
 | |
| ---
 | |
|  at.c | 5 +++++
 | |
|  1 file changed, 5 insertions(+)
 | |
| 
 | |
| diff --git a/at.c b/at.c
 | |
| index 2136e0b..d65168d 100644
 | |
| --- a/at.c
 | |
| +++ b/at.c
 | |
| @@ -860,6 +860,11 @@ main(int argc, char **argv)
 | |
|  		fprintf(stderr, "invalid date format: %s\n", optarg);
 | |
|  		exit(EXIT_FAILURE);
 | |
|  	    }
 | |
| +	    /* Check if the parsed time is in the past */
 | |
| +	    if (timer < time(NULL)) {
 | |
| +		fprintf(stderr, "at: refusing to create job destined in the past\n");
 | |
| +		exit(EXIT_FAILURE);
 | |
| +	    }
 | |
|  	    /* drop seconds */
 | |
|  	    timer -= timer % 60;
 | |
|  	    break;
 | |
| -- 
 | |
| 2.50.0
 | |
| 
 |