But we are not continuing to scan into the junk here to get more tokens here; we don't have a loop that will cause O(N*N) behavior.
E.g. this could be user input from a form field where they are expected to type a date, and we want to reject that if there is trailing junk. At that point, the user gets an error, and has to fix the input. We don't look for anything in the trailing junk.
It's not about "scanning into junk". The problem would happen if you used scanf to extract integers from a string of `' '.join([1]*1000000)`. Because you would make 1,000,000 scanf calls, and _each_ of those calls would call strlen on the string, quadratically scanning over the string to repeatedly find the end.
In fact, every sscanf is O(size of the string) even when the string is well formed. This is not a well behaved function.