* resolve.c (main): copy the address sent back by gethostbyname
authorMark Eichin <eichin@mit.edu>
Wed, 26 Apr 1995 02:18:34 +0000 (02:18 +0000)
committerMark Eichin <eichin@mit.edu>
Wed, 26 Apr 1995 02:18:34 +0000 (02:18 +0000)
before calling gethostbyaddr, since the return is *static*.
(main): reindent declaration to make add-change-log-entry happy.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5483 dc483132-0cff-0310-8789-dd5450dbe970

src/tests/resolve/ChangeLog [new file with mode: 0644]
src/tests/resolve/resolve.c

diff --git a/src/tests/resolve/ChangeLog b/src/tests/resolve/ChangeLog
new file mode 100644 (file)
index 0000000..4255622
--- /dev/null
@@ -0,0 +1,6 @@
+Tue Apr 25 22:16:38 1995  Mark Eichin  <eichin@cygnus.com>
+
+       * resolve.c (main): copy the address sent back by gethostbyname
+       before calling gethostbyaddr, since the return is *static*.
+       (main): reindent declaration to make add-change-log-entry happy.
+
index f89ecb1369b7e6245b70d147d735772baf743893..71a7bc44f3329e4394f2e96c7653847aecde621d 100644 (file)
@@ -59,12 +59,14 @@ char *strchr();
 
 #include <netdb.h>
 
+int
 main(argc, argv)
-int argc;
-char **argv;
+     int argc;
+     char **argv;
 {
        char myname[MAXHOSTNAMELEN+1];
        char *ptr;
+       char addrcopy[4];
        struct hostent *host;
        int err;
 
@@ -96,8 +98,10 @@ char **argv;
        printf("Host address: %d.%d.%d.%d\n", 
               UC(ptr[0]), UC(ptr[1]), UC(ptr[2]), UC(ptr[3]));
 
+       memcpy(addrcopy, ptr, 4);
+
        /* Convert back to full name */
-       if((host = gethostbyaddr(ptr, 4, AF_INET)) == NULL) {
+       if((host = gethostbyaddr(addrcopy, 4, AF_INET)) == NULL) {
                fprintf(stderr, "Error looking up IP address - fatal\n");
                exit(2);
        }