Page MenuHomeFreeBSD

libstand: verify value provided by nfs.read_size
ClosedPublic

Authored by tsoome on Nov 10 2016, 1:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 9 2024, 7:19 PM
Unknown Object (File)
Jan 26 2024, 10:18 PM
Unknown Object (File)
Jan 22 2024, 1:05 AM
Unknown Object (File)
Jan 9 2024, 10:17 AM
Unknown Object (File)
Dec 22 2023, 9:30 PM
Unknown Object (File)
Dec 11 2023, 10:38 PM
Unknown Object (File)
Dec 4 2023, 8:18 AM
Unknown Object (File)
Nov 28 2023, 9:41 PM
Subscribers

Details

Summary

Implement simple value check and feedback.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 5911
Build 6197: arc lint + arc unit

Event Timeline

tsoome retitled this revision from to libstand: verify value provided by nfs.read_size.
tsoome updated this object.
tsoome edited the test plan for this revision. (Show Details)
tsoome added reviewers: allanjude, imp.

Should be *env == '\0' ...

julian added a reviewer: julian.
julian added a subscriber: julian.

looks reasonable, but am unsure of all the possible cases for *end given garbage input

This revision is now accepted and ready to land.Nov 10 2016, 2:32 PM
tsoome edited edge metadata.

Add notification about resetting the value for nfs_read_size.

This revision now requires review to proceed.Nov 11 2016, 6:32 PM
tsoome edited edge metadata.

Factored out the set_nfs_read_size(), as the r305588 did miss the fact
we have not one but two versions of nfs_getrootfh() and we need to set
the nfs_read_size in both.

Since we can ignore the user provided value, reset the environment
with actually used value so we will not get the repeated messages about
bad value.

rpokala requested changes to this revision.Mar 15 2017, 9:04 PM
rpokala added inline comments.
lib/libstand/nfs.c
228

nfs_read_size is (int); while strtol() returns (long); cast accordingly.

229

Is it legal to check for non-zero errno? I thought errno in general is only set to a non-zero value of failure, but not set to zero on success. So, a previous failure would set errno to non-zero, and it would stay non-zero even if the getenv() succeeded.

This revision now requires changes to proceed.Mar 15 2017, 9:04 PM
tsoome edited edge metadata.
tsoome marked an inline comment as done.

Typo in errno name and casting to int.

lib/libstand/nfs.c
228

well, the compiler should take care, but I do not mind anyhow:)

229

I set it 0 at line 227 (modulo typo;), so w have it set 0 just before the call to strtol.

lib/libstand/nfs.c
229

Right, but I'm not sure that's actually legal. I know in some contexts errno is actually a function-like macro or something wacky, so for example different threads don't stomp on it. Granted, that might not be relevant in the context of the bootloader. :-)

In any case, the rule I learned is "never set errno to zero, only to non-zero on failure".

lib/libstand/nfs.c
229

Well yes, standalone boot is a special environment and as here we run as one big single threaded app, there is nothing to reset it for us and since libstand does not reset it either, we can have errno set anywhere else and not in strtol() so we can end up having errno == ERANGE from anywhere but strtol() itself:)

This revision is now accepted and ready to land.Mar 15 2017, 9:44 PM
This revision was automatically updated to reflect the committed changes.