jpl_eph icon indicating copy to clipboard operation
jpl_eph copied to clipboard

error while 'sudo make'

Open ravbin opened this issue 3 years ago • 2 comments

opened terminal in the directory and wrote 'sudo make' after copying get_bin.h into the folder. this is the output:

Screenshot_20230408_032922 Screenshot_20230408_032934

ravbin avatar Apr 08 '23 00:04 ravbin

Hi @ravbin - I don't see this, but I will bet you it's because we have different versions of gcc/g++. Some versions spot potential overflows that others don't; some issue spurious warnings (which this one is) where others don't.

In this case, I think if you insert the line

      assert( ival >= 0L && ival < 1000000000L);

right before the snprintf() call in question, the error will go away. The reality is that ival will be within the above range, and therefore the snprintf() will not actually overflow the buffer. Later versions of g++ are bright enough to figure this out on their own (which I find really impressive) in most cases, but even then, I sometimes have to add a line such as the above.

With the assert in place, the compiler will think "well, ival will be within the specified range by the time we get to the snprintf(), and won't have enough digits to overflow." And all will compile.

Please let me know if that works. (I'm about 99% sure it will, but there's always that 1%.) If it does, I'll modify the code appropriately and push the change to this library.

You also should be able to build as a non-root user.

Bill-Gray avatar Apr 08 '23 03:04 Bill-Gray

Yes it solved the problem! Thank you so much.

ravbin avatar Apr 08 '23 09:04 ravbin