Page MenuHomeFreeBSD

Various fixes to the load() function.
ClosedPublic

Authored by jhb on Sep 1 2020, 4:22 PM.
Tags
None
Referenced Files
F150085808: D26278.diff
Sun, Mar 29, 6:49 AM
F150039683: D26278.id.diff
Sat, Mar 28, 10:33 PM
F150031935: D26278.id76611.diff
Sat, Mar 28, 9:18 PM
Unknown Object (File)
Wed, Mar 25, 2:27 AM
Unknown Object (File)
Sun, Mar 22, 6:21 PM
Unknown Object (File)
Tue, Mar 10, 2:48 PM
Unknown Object (File)
Fri, Mar 6, 1:22 PM
Unknown Object (File)
Fri, Mar 6, 1:24 AM
Subscribers

Details

Summary
  • Use getline() instead of fgetln(). This ensures the returned string is always null-terminated without losing the last character if the last line in a file doesn't have a newline. Also, while fgetln says the returned buffer can be modified, that doesn't actually seem safe as the current implementation means you are modifying stdio's internal buffer.
  • Remove a spurious if before an ATF_REQUIRE that was clearly supposed to be non-optional.
  • Remove a pointless compare of 'ptr' against '\0' (really NULL) that duplicated the middle condition in the for().
  • Once a comment is found, skip the rest of the line, not just the current word.
Test Plan
  • ran the resolv_test tests

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Sep 1 2020, 4:22 PM
jhb created this revision.
lib/libc/tests/resolv/resolv_test.c
88 ↗(On Diff #76498)

free(line);

LGTM modulo the memory leak pointed out by brooks.

  • Free the line in load().
This revision is now accepted and ready to land.Sep 3 2020, 2:27 PM
This revision was automatically updated to reflect the committed changes.