Page MenuHomeFreeBSD

Fix up getlocalbase() implementation
Needs ReviewPublic

Authored by scottl on Nov 15 2020, 7:03 PM.

Details

Reviewers
jrtc27
bapt
bdrewery
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Summary

There are several problems with data types, casts, and checks in
getlocalbase(). This attempts to fix them

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 34810
Build 31851: arc lint + arc unit

Event Timeline

lib/libutil/getlocalbase.c
77

strlcpy doesn't include the NUL so this to stay >=.

lib/libutil/getlocalbase.c
53–54

This should probably be EINVAL (and could then be folded into the previous if).

Fix items suggested by Jessica, move to sysctlnametomib() to account for
inconsistencies in the user/kernel interface

Owners added a reviewer: Restricted Owners Package.Nov 15 2020, 7:54 PM
lib/libutil/getlocalbase.c
59

miblen is currently uninitialised before the call; presumably it works because it's reading random garbage on the stack that's most likely >= 2. You should probably also be checking the return value here.