GeoscienceAustralia / astro-code

Apache License 2.0
3 stars 5 forks source link

sunrisenset.c - dumps core by default #4

Closed casa-henrym closed 1 month ago

casa-henrym commented 1 month ago

The first thing this programme does is dereference argv without first checking that this is a valid pointer! Calling without any arguments dumps core - this is very poor behaviour; at the least it should print "usage" information. In fact, this behaviour is doubly confusing because, according to the Purpose, documented at the top of the file, the programme should be reading its input from stdin.

In my particular case I need to calculate dawn and dusk times for a large number of dates (1000s) and locations (100s) and the overhead of calling the programme many times is going to be a large part of the total time in making these calculations. If the programme did read from stdin, as the comments suggest it should, I could avoid this overhead.

How do you calculate the "annual" times, for that option on the website? Do you invoke this programme 365 times?

I'll probably change this programme to read from stdin so that I can make my calculations with one process - but I wonder if you already have a separate programme to do this.

casa-henrym commented 1 month ago

OK, I can answer my own question: a date parameter can be just the year, in which case the values for the year are returned. I have discovered that there is no validation for dates, so invalid dates (e.g. 33/07/2024) can be entered and will return a response. Modifying sunrisenset.c to take input on stdin is quite trivial: was there a reason it wasn't done this way? (the way it was documented to work).

harry093 commented 1 month ago

Hi Michael, thanks for raising this issue. This code is used for our online app, which you can find here.

https://geodesyapps.ga.gov.au/sunrise

The code was initially written many years ago by a person who no longer works at GA. It was hosted on a Sun Solaris machine and was re-written to port to AWS when that Sun machine was decommissioned and the code made open source.

You are welcome to copy and modify the code any way you see fit within the conditions of the Apache License 2.0.

aviast commented 1 month ago

Thanks for your response @harry093. This code is not just used for the online app. I believe this code is used to calculate "official" dawn and dusk times for pilots who get this information from NAIPS. There are many libraries that calculate dawn/dusk/sunrise/sunset, but none of them quite agree. While they only differ from each other by a few minutes, I require the official times as I'm using this in an aviation context. I do worry, from looking at the code quality (e.g. core dump), whether this app is really fit for purpose.

harry093 commented 1 month ago

Geoscience Australia is not responsible for services provided by other organisations. I suggest you contact Airservices Australia directly.

We have no plans to develop this code any further at this point in time.