Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Of course, this should never happen but can be difficult to guarantee when the limits are derived from user inputs.

Sounds to me like you are missing a validation step before calling your logic. When it comes to parsing, trusting user input is a recipe for disaster in the form of buffer overruns and potential exploits.

As they used to say in the Soviet Union: "trust, but verify".



The answer is of course

    clamp(min(a,b), max(a,b))
classic c++


That was what Reagan said about the Soviet Union, not what was said in the Soviet Union.

Correct me if I'm wrong.


https://en.wikipedia.org/wiki/Trust,_but_verify

> Trust, but verify (Russian: доверяй, но проверяй, tr. doveryay, no proveryay, IPA: [dəvʲɪˈrʲæj no prəvʲɪˈrʲæj]) is a Russian proverb, which is rhyming in Russian. The phrase became internationally known in English after Suzanne Massie, a scholar of Russian history, taught it to Ronald Reagan, then president of the United States, the latter of whom used it on several occasions in the context of nuclear disarmament discussions with the Soviet Union.

Memorably referenced in "Chernobyl": https://youtu.be/9Ebah_QdBnI?t=79


Also referenced in the Metro Exodus "Sam's Story" DLC because of the backstory of the two characters speaking, and nuclear weapons once again being part of the scenario.


When I hear the phrase, I rewrite it to "don't trust, verify."


Thanks for the clarification/explanation!


Russian here. We use that expression from time to time: https://ya.ru/search/?text="доверяй%2C+но+проверяй"


According to wikipedia you're right (about Reagan) but it's also a Russion proverb.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: