diff options
Diffstat (limited to 'lib/safe_net.c')
-rw-r--r-- | lib/safe_net.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/safe_net.c b/lib/safe_net.c index 1717f0745..5dec0de11 100644 --- a/lib/safe_net.c +++ b/lib/safe_net.c @@ -469,6 +469,23 @@ int safe_gethostname(const char *file, const int lineno, return rval; } +int safe_sethostname(const char *file, const int lineno, + const char *name, size_t size) +{ + int rval = sethostname(name, size); + + if (rval == -1) { + tst_brkm_(file, lineno, TBROK | TERRNO, NULL, + "sethostname(%p, %zu) failed", name, size); + } else if (rval) { + tst_brkm_(file, lineno, TBROK | TERRNO, NULL, + "Invalid sethostname(%p, %zu) return value %d", name, + size, rval); + } + + return rval; +} + /* * @return port in network byte order. */ |