View Single Post
Old 06-24-2019, 04:31 PM   #143
sherman
Guru
sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.
 
Posts: 876
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
Quote:
Originally Posted by NiLuJe View Post
@frostschutz: Pushed the linefeeds fixes .

@sherman: They're here. I *think* that's a somewhat sensible approach, but you're probably more familiar with this logic than I am. It's mostly all related to not calling u8_dec when the index is 0, as it would happily look *before* the buffer, and underflow the index.

Besides the test-cases provided by @frostschutz, the only other edge-case I could actually trigger is with a single character *right* above the size limit. I couldn't actually trigger a crash, but I did get an underflow, and by chance it happened to find a bogus break (very) soon after the wrapped-around value, so it mostly slipped through the cracks unnoticed.
Now it reliably aborts with the proper "you blew the LW" error.
Looks like it should be ok. Bit of an oopsie there wasn't it. I might have been inclined to just strip leading/trailing linebreaks, but your solution is probably more correct.

I'm writing this while awaiting a flight at San Diego airport, so take my "review" with a dash of salt...
sherman is offline   Reply With Quote