Page MenuHomeFreeBSD

Fix up getlocalbase() implementation
Needs ReviewPublic

Authored by scottl on Nov 15 2020, 7:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 9, 7:32 PM
Unknown Object (File)
Feb 21 2024, 4:21 PM
Unknown Object (File)
Jan 12 2024, 4:12 PM
Unknown Object (File)
Jan 3 2024, 8:02 PM
Unknown Object (File)
Dec 23 2023, 4:03 AM
Unknown Object (File)
Dec 1 2023, 3:53 PM
Unknown Object (File)
Nov 15 2023, 9:33 PM
Unknown Object (File)
Nov 14 2023, 7:41 PM
Subscribers

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 Passed
Unit
No 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
60

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.