Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error while 'sudo make' #11

Open
ravbin opened this issue Apr 8, 2023 · 2 comments
Open

error while 'sudo make' #11

ravbin opened this issue Apr 8, 2023 · 2 comments

Comments

@ravbin
Copy link

ravbin commented Apr 8, 2023

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

@Bill-Gray
Copy link
Owner

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.

@ravbin
Copy link
Author

ravbin commented Apr 8, 2023

Yes it solved the problem! Thank you so much.

Bill-Gray added a commit that referenced this issue Apr 11, 2023
…verflow warning because they don't 'see' that the buffer never will, in fact, overflow. An assert() tells the compiler (and anyone reading the code) that this will not be a problem.
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

No branches or pull requests

2 participants