X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-gethostname.c;h=c500f416097d1a7d33d220aae7dfe97f8e4549f5;hb=f5d7314bdeb3d2022ed572f48feba6546baf5f5b;hp=01f9369934b2e1de70bf3a0973f93856fd808a27;hpb=68751d7e5ffc50cc9555b4e1643dcaebda72c60e;p=gnulib.git diff --git a/tests/test-gethostname.c b/tests/test-gethostname.c index 01f936993..c500f4160 100644 --- a/tests/test-gethostname.c +++ b/tests/test-gethostname.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Free Software Foundation + * Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. * Written by Simon Josefsson. * * This program is free software: you can redistribute it and/or modify @@ -17,19 +17,33 @@ #include +/* Get gethostname() declaration. */ +#include + +#include "signature.h" +SIGNATURE_CHECK (gethostname, int, (char *, size_t)); + +/* Get HOST_NAME_MAX definition. */ +#include + #include #include #include -#include #define NOHOSTNAME "magic-gnulib-test-string" int -main (int argc, char *argv[]) +main (int argc, char *argv[] _GL_UNUSED) { - char buf[2500]; + char buf[HOST_NAME_MAX]; int rc; + if (strlen (NOHOSTNAME) >= HOST_NAME_MAX) + { + printf ("HOST_NAME_MAX impossibly small?! %d\n", HOST_NAME_MAX); + return 2; + } + strcpy (buf, NOHOSTNAME); rc = gethostname (buf, sizeof (buf));