
January 2021. Qualys researchers reveal Baron Samedit, a bug that sat in sudo for almost ten years and let any local user become root. The heart of it was sudo mishandling backslash escapes while measuring a command line: it got the decoded length wrong and overran a buffer. Here is that measurement, done safely. A backslash escapes the next character, so an escape pair counts as one, and a lone backslash at the very end must not send you reading past the string.
Repair this code
Repair the length count so each backslash escape folds into a single character.
Steps
$ decoded_len("abc")
3
$ decoded_len("x\\ny")
3
$ decoded_len("a\\")
2
Expected files
Allowed functions
None. Write every helper yourself.
Loading solutions...