sbvarsign: fix "EFI_VARIABLE_AUTHENTICATION_2.TimeStamp.Year" assignment

According to UEFI-2.8, section 8.3 "Time Services" / GetTime(), the
"EFI_TIME.Year" field must be in the range [1900, 9999] (both bounds
inclusive). It is not stated or even implied that "EFI_TIME.Year" would
not be an absolute year number.

According to POSIX, the "tm_year" field of "struct tm" is defined as
"Years since 1900". In other words, "tm_year" is relative to 1900.

In set_timestamp(), time() and gmtime() are suitable for populating
"EFI_VARIABLE_AUTHENTICATION_2.TimeStamp", as the UEFI spec specifically
requires a stamp expressed in the GMT (UTC) zone. But we still need to
offset "tm->tm_year" by 1900 for filling in "timestamp->Year". So let's do
that now.

While this issue does not seem to affect upstream edk2, SetVariable()
calls with payloads containing an invalid
"EFI_VARIABLE_AUTHENTICATION_2.TimeStamp.Year" value do seem to be
rejected at least on some Dell Inspiron machines (using a UEFI
implementation from AMI).

Reported-by: Eugene Khoruzhenko <ekhoruzhenko@absolute.com>
Reported-by: Paulo Henrique Lacerda de Amorim <phlamorim@riseup.net>
Ref: https://edk2.groups.io/g/devel/message/49402
Fixes: 953b00481f3957fc756a6dc7d10c570da32a08bc
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
diff --git a/src/sbvarsign.c b/src/sbvarsign.c
index ebf625c..273fd0d 100644
--- a/src/sbvarsign.c
+++ b/src/sbvarsign.c
@@ -212,7 +212,7 @@
 	/* copy to our EFI-specific time structure. Other fields (Nanosecond,
 	 * TimeZone, Daylight and Pad) are defined to be zero */
 	memset(timestamp, 0, sizeof(*timestamp));
-	timestamp->Year = tm->tm_year;
+	timestamp->Year = 1900 + tm->tm_year;
 	timestamp->Month = tm->tm_mon;
 	timestamp->Day = tm->tm_mday;
 	timestamp->Hour = tm->tm_hour;