Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 73cf865

Browse files
committed
Add a newline after hostname entry
Always add a newline after printing the hostname: entry, just in case userdata API call returns *just* the hostname. Update the test data to just such a bare hostname. Fixes #59
1 parent 5cb6a23 commit 73cf865

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/ucd-data-fetch.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,16 @@ int main(int argc, char *argv[]) {
445445
}
446446

447447
/* don't write part #2 if 404 or some non-error */
448-
if ((result != 2) && (write_lines(out, f, cl, "hostname: ") != 0)) {
449-
close(out);
450-
fclose(f);
451-
unlink(outpath);
452-
FAIL("write_lines()");
448+
if (result != 2) {
449+
if (write_lines(out, f, cl, "hostname: ") != 0) {
450+
close(out);
451+
fclose(f);
452+
unlink(outpath);
453+
FAIL("write_lines()");
454+
}
455+
456+
/* Write an extra linefeed in case userdata hostname didn't end with one */
457+
write(out, "\n", 1);
453458
}
454459

455460
/* cleanup */

tests/fetch_data/hostname

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
myhostname
1+
myhostname

0 commit comments

Comments
 (0)