This commit was manufactured by cvs2svn to create tag
[krb5.git] / src / slave / kprop.c
index 3c4848135af47fa85eed212cb886a1ca66e8c67a..fa32f11a8432b6492e4c9e2aca78c695a7c5f30a 100644 (file)
  * this permission notice appear in supporting documentation, and that
  * the name of M.I.T. not be used in advertising or publicity pertaining
  * to distribution of the software without specific, written prior
- * permission.  M.I.T. makes no representations about the suitability of
+ * permission.  Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
  * this software for any purpose.  It is provided "as is" without express
  * or implied warranty.
  * 
@@ -69,7 +72,7 @@ void  get_tickets
 static void usage 
        PROTOTYPE((void));
 krb5_error_code open_connection 
-       PROTOTYPE((char *, int *, char *));
+       PROTOTYPE((char *, int *, char *, int));
 void   kerberos_authenticate 
        PROTOTYPE((krb5_context, krb5_auth_context *, 
                   int, krb5_principal, krb5_creds **));
@@ -92,7 +95,7 @@ static void usage()
        exit(1);
 }
 
-void
+int
 main(argc, argv)
        int     argc;
        char    **argv;
@@ -113,7 +116,7 @@ main(argc, argv)
        get_tickets(context);
 
        database_fd = open_database(context, file, &database_size);
-       if (retval = open_connection(slave_host, &fd, Errmsg)) {
+       if (retval = open_connection(slave_host, &fd, Errmsg, sizeof(Errmsg))) {
                com_err(progname, retval, "%s while opening connection to %s",
                        Errmsg, slave_host);
                exit(1);
@@ -304,10 +307,11 @@ void get_tickets(context)
 }
 
 krb5_error_code
-open_connection(host, fd, Errmsg)
+open_connection(host, fd, Errmsg, ErrmsgSz)
        char    *host;
        int     *fd;
        char    *Errmsg;
+       int      ErrmsgSz;
 {
        int     s;
        krb5_error_code retval;
@@ -324,12 +328,13 @@ open_connection(host, fd, Errmsg)
                return(0);
        }
        sin.sin_family = hp->h_addrtype;
-       memcpy((char *)&sin.sin_addr, hp->h_addr, hp->h_length);
+       memcpy((char *)&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr));
        if(!port) {
                sp = getservbyname(KPROP_SERVICE, "tcp");
                if (sp == 0) {
-                       (void) strcpy(Errmsg, KPROP_SERVICE);
-                       (void) strcat(Errmsg, "/tcp: unknown service");
+                       (void) strncpy(Errmsg, KPROP_SERVICE, ErrmsgSz - 1);
+                       Errmsg[ErrmsgSz - 1] = '\0';
+                       (void) strncat(Errmsg, "/tcp: unknown service", ErrmsgSz - 1 - strlen(Errmsg));
                        *fd = -1;
                        return(0);
                }
@@ -478,7 +483,8 @@ open_database(context, data_fn, size)
                com_err(progname, ENOMEM, "while trying to malloc data_ok_fn");
                exit(1);
        }
-       strcat(strcpy(data_ok_fn, data_fn), ok);
+       strcpy(data_ok_fn, data_fn);
+       strcat(data_ok_fn, ok);
        if (stat(data_ok_fn, &stbuf_ok)) {
                com_err(progname, errno, "while trying to stat %s",
                        data_ok_fn);
@@ -546,11 +552,11 @@ xmit_database(context, auth_context, my_creds, fd, database_fd, database_size)
                exit(1);
        }
        if (retval = krb5_write_message(context, (void *) &fd, &outbuf)) {
-               krb5_xfree(outbuf.data);
+               krb5_free_data_contents(context, &outbuf);
                com_err(progname, retval, "while sending database size");
                exit(1);
        }
-       krb5_xfree(outbuf.data);
+       krb5_free_data_contents(context, &outbuf);
     /*
      * Initialize the initial vector.
      */
@@ -577,13 +583,13 @@ xmit_database(context, auth_context, my_creds, fd, database_fd, database_size)
                        exit(1);
                }
                if (retval = krb5_write_message(context, (void *)&fd,&outbuf)) {
-                       krb5_xfree(outbuf.data);
+                       krb5_free_data_contents(context, &outbuf);
                        com_err(progname, retval,
                                "while sending database block starting at %d",
                                sent_size);
                        exit(1);
                }
-               krb5_xfree(outbuf.data);
+               krb5_free_data_contents(context, &outbuf);
                sent_size += n;
                if (debug)
                        printf("%d bytes sent.\n", sent_size);
@@ -674,7 +680,7 @@ send_error(context, my_creds, fd, err_text, err_code)
                strcpy(error.text.data, text);
                if (!krb5_mk_error(context, &error, &outbuf)) {
                        (void) krb5_write_message(context, (void *)&fd,&outbuf);
-                       krb5_xfree(outbuf.data);
+                       krb5_free_data_contents(context, &outbuf);
                }
                free(error.text.data);
        }