Got it. Looks good! Will be in the next release

Ken Jones

Brian Kolaci wrote:
> 
> In the file vchkpw.c:
> 
> around line 386, in the function "host_in_locals(domain)"
> 
> There's a memory and file pointer leak.
> 
> OLD:
> 
> int host_in_locals(domain)
>  char *domain;
> {
>  int i;
>         char *tmpbuf;
>         FILE *fs;
> 
>         tmpbuf = malloc(slen(QMAILDIR) + 18 );
> 
>         sprintf(tmpbuf, "%s/control/locals", QMAILDIR);
>         fs = fopen(tmpbuf,"r");
>         if ( fs == NULL ) {
>                 return(0);
>         }
> 
>         while( fgets(tmpbuf,200,fs) != NULL ) {
>                 for(i=0;tmpbuf[i]!=0;++i) if (tmpbuf[i]=='\n') tmpbuf[i]=0;
>                 if ( sstrcmp( domain, tmpbuf ) == 0 ) {
>                         return(1);
>                 }
>                 if ( sstrcmp(domain, "localhost") == 0 &&
>                          strstr(domain,"localhost") != NULL ) {
>                         return(1);
>                 }
>         }
> 
>         fclose(fs);
>         return(0);
> }
> 
> NEW:
> 
> int host_in_locals(domain)
>  char *domain;
> {
>  int i;
>         char *tmpbuf;
>         FILE *fs;
> 
>         tmpbuf = malloc(slen(QMAILDIR) + 18 );
> 
>         sprintf(tmpbuf, "%s/control/locals", QMAILDIR);
>         fs = fopen(tmpbuf,"r");
>         if ( fs == NULL ) {
>                 free(tmpbuf);
>                 return(0);
>         }
> 
>         while( fgets(tmpbuf,200,fs) != NULL ) {
>                 for(i=0;tmpbuf[i]!=0;++i) if (tmpbuf[i]=='\n') tmpbuf[i]=0;
>                 if ( sstrcmp( domain, tmpbuf ) == 0 ) {
>                         free(tmpbuf);
>                         fclose(fs);
>                         return(1);
>                 }
>                 if ( sstrcmp(domain, "localhost") == 0 &&
>                          strstr(domain,"localhost") != NULL ) {
>                         free(tmpbuf);
>                         fclose(fs);
>                         return(1);
>                 }
>         }
> 
>         free(tmpbuf);
>         fclose(fs);
>         return(0);
> }

Reply via email to