Skip to content

Reject a TLE whose epoch field contains a letter - #430

Merged
csete merged 1 commit into
csete:masterfrom
Wahaj18:fix-427-tle-epoch-letter
Oct 10, 2026
Merged

csete merged 1 commit into
csete:masterfrom
Wahaj18:fix-427-tle-epoch-letter

Conversation

@Wahaj18

@Wahaj18 Wahaj18 commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #427.

Checksum_Good() counts any character other than a digit or - as 0, so a letter that replaces a 0 in the epoch field (columns 19-32 of line 1) leaves the checksum valid. Good_Elements() accepted such a set, and Convert_Satellite_Data() then read the epoch only up to the letter. With the example from the issue the epoch moves 14 min 16 s early without any error.

This adds a check to Good_Elements() that the epoch field is a well-formed number:

  • a two digit year,
  • a three digit day of year, whose two leading digits may be padded with spaces (the case Convert_Satellite_Data() already handles),
  • a fraction of day made of digits, followed by nothing but trailing spaces.

A set that fails the check is rejected the same way as one with a bad checksum, so Get_Next_Tle_Set() returns -2 and the TLE update and satellite loading code skip it.

Testing

  • test-001 now builds a copy of its element set with O in place of a 0 in the epoch and fails if Good_Elements() accepts it, and also checks that a space-padded day of year is still accepted. It fails without the change and passes with it.
  • ./autogen.sh && make && make check pass; test-001 and test-002 pass.
  • All 15941 element sets in the current CelesTrak active list are still accepted by Get_Next_Tle_Set(), before and after the change.

Checksum_Good() counts any character other than a digit or '-' as 0,
so a letter that replaced a 0 in the epoch (columns 19-32 of line 1)
keeps the checksum valid. Good_Elements() accepted such a set and
Convert_Satellite_Data() then read the epoch only up to the letter,
moving it by minutes without any error.

Check in Good_Elements() that the epoch field is a well-formed number:
a two digit year, a three digit day of year whose leading digits may
be padded with spaces, and a fraction of day made of digits, followed
by nothing but trailing spaces. test-001 now fails if a letter in the
epoch is accepted or if a space-padded day of year is rejected.

All 15941 element sets in the current CelesTrak active list are still
accepted.

Fixes csete#427
@csete

csete commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thanks, it's merged

@csete
csete merged commit f05abf3 into csete:master Oct 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A letter in a TLE's epoch field passes Good_Elements() and the epoch is read up to it

2 participants