Skip to content

Commit

Permalink
'fo' was overly restrictive about specifying lat/lon observing points…
Browse files Browse the repository at this point in the history
… for ephemerides. The location had to fit in less than nine bytes. Also, if no location was specified, you could easily get an out-of-bounds array access.
  • Loading branch information
Bill-Gray committed May 24, 2023
1 parent 9d53950 commit a65e8e8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ static const char *get_arg( const int argc, const char **argv, const int idx)

int main( int argc, const char **argv)
{
char tbuff[300], *mpc_codes = (char *)malloc( 1);
char tbuff[300], *mpc_codes = (char *)malloc( 20);
char **summary_lines = NULL;
const char *separate_residual_file_name = NULL;
const char *mpec_path = NULL;
Expand Down Expand Up @@ -966,12 +966,12 @@ int main( int argc, const char **argv)
}
while( *mpc_code_tptr)
{
char mpc_code[10], ephem_filename[200];
char mpc_code[20], ephem_filename[200];

j = 0;
while( j < 9 && *mpc_code_tptr > ' ' && *mpc_code_tptr != ',')
while( j < sizeof( mpc_code) && *mpc_code_tptr > ' ' && *mpc_code_tptr != ',')
mpc_code[j++] = *mpc_code_tptr++;
assert( j < 9);
assert( j < sizeof( mpc_code));
mpc_code[j] = '\0';
while( *mpc_code_tptr == ' ' || *mpc_code_tptr == ',')
mpc_code_tptr++;
Expand Down

0 comments on commit a65e8e8

Please sign in to comment.