Page MenuHomeFreeBSD

[fgetstr] Handle case if len is negative
AbandonedPublic

Authored by gfunni234_gmail.com on Aug 24 2021, 6:05 PM.

Details

Reviewers
imp
jrtc27
dim
Summary

This shouldn’t happen, but if it does, it’s good to have a fallback, lest the loop be stuck until an underflow happens.

It’s not as if it won’t be obvious anymore if a bug happens due to a bad input, but the impact should be lessened.

MFC

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

This is now harder to read. If the input size is between INT_MIN (exclusive) and 0 (inclusive) you still overflow buf. If the input is exactly INT_MIN you still have signed integer overflow. This therefore adds nothing of value.