Bug 221854

Summary: makefs: Reject UFS labels that are too long to fit
Product: Base System Reporter: Fabian Keil <fk>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Some People CC: emaste, pstef
Priority: --- Keywords: patch
Version: CURRENTFlags: fk: mfc-stable11?
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210463
Attachments:
Description Flags
makefs: Reject UFS labels that are too long to fit none

Description Fabian Keil 2017-08-27 10:49:53 UTC
Created attachment 185810 [details]
makefs: Reject UFS labels that are too long to fit

If a specified UFS label is too long to fit, makefs currently silently truncates it.

This causes problems if the created file system contains files like
/etc/fstab that expect the whole label.

You may end up with a release image that was built "successfully"
but doesn't actually boot.

The attached patch lets makefs reject UFS labels that don't fit which
makes the issue easier to spot.

Obtained from: ElectroBSD
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2018-05-20 23:51:40 UTC
For bugs matching the following conditions:
- Status == In Progress
- Assignee == "bugs@FreeBSD.org"
- Last Modified Year <= 2017

Do
- Set Status to "Open"
Comment 2 Piotr Pawel Stefaniak freebsd_committer freebsd_triage 2021-09-30 21:02:51 UTC
In 2017, Ed imported option parsing from NetBSD so this patch no longer applies. While I support the improvement, it has the side effect that since all strings are handled like this:
		case OPT_STRARRAY:
			strlcpy((void *)options[i].value, val, (size_t)
			    options[i].maximum);
			break;
you can't be selective about which truncation is tolerable and which is not.

Ed, maybe we should reject any and all truncation errors in this path?