[12875] in Athena Bugs

home help back first fref pref prev next nref lref last post

Re: MH memory handling bug

daemon@ATHENA.MIT.EDU (Richard Basch)
Fri Nov 11 14:59:44 1994

Date: Fri, 11 Nov 1994 14:59:35 -0500
To: ghudson@MIT.EDU
Cc: bugs@MIT.EDU, linux-dev@MIT.EDU
In-Reply-To: ghudson@MIT.EDU's message of Fri, 11 Nov 94 12:37:20 -0500,
	<9411111737.AA20853@maze.MIT.EDU>
From: "Richard Basch" <basch@MIT.EDU>


There is a bug in the patch... you should malloc(strlen(...) + 1)...

-Richard

   From: ghudson@MIT.EDU
   Date: Fri, 11 Nov 94 12:37:20 -0500


   zotnet/mts/client.c calls krb_sendauth() and krb_realmofhost() with a
   pointer to static data in a hostent structure.  Since krb_sendauth()
   may make calls to gethostbyname() and gethostbyaddr(), this causes
   problems.  This shows up under Linux, and probably on other platforms
   if you do reverse resolution in the Kerberos library.  Here is a
   patch:

   *** /afs/dev/source/src/third/supported/mh.6.8/zotnet/mts/client.c      Fri Jan 29 23:41:47 1993
   --- client.c    Fri Nov 11 12:30:59 1994
   ***************
   *** 253,265 ****
     
     #ifdef KPOP
         if (kservice) {   /* "pop" */
           ticket = (KTEXT)malloc( sizeof(KTEXT_ST) );
   !       rem = krb_sendauth(0L, sd, ticket, kservice, hp->h_name,
   !                          (char *) krb_realmofhost(hp->h_name),
                              (unsigned long)0, &msg_data, &cred, schedule,
                              (struct sockaddr_in *)NULL,
                              (struct sockaddr_in *)NULL,
                              "KPOPV0.1");
           if (rem != KSUCCESS) {
               close(sd);
               (void) strcpy(response, "Post office refused connection: ");
   --- 253,269 ----
     
     #ifdef KPOP
         if (kservice) {   /* "pop" */
   +       char *host_save;
   +       host_save = malloc(strlen(hp->h_name));
   +       strcpy(host_save, hp->h_name);
           ticket = (KTEXT)malloc( sizeof(KTEXT_ST) );
   !       rem = krb_sendauth(0L, sd, ticket, kservice, host_save,
   !                          (char *) krb_realmofhost(host_save),
                              (unsigned long)0, &msg_data, &cred, schedule,
                              (struct sockaddr_in *)NULL,
                              (struct sockaddr_in *)NULL,
                              "KPOPV0.1");
   +       free(host_save);
           if (rem != KSUCCESS) {
               close(sd);
               (void) strcpy(response, "Post office refused connection: ");

home help back first fref pref prev next nref lref last post