On Mon, Jan 11, 2016 at 10:25:47AM +0100, Alexis VACHETTE wrote:
> Hi,
> 
> It was stated last week that OpenSMTPD daemon doesn't throw any warning if a
> specific table isn't readable by OpenSMTPD user.
> 
> I made a patch for the portable version on github :
> 
> *** a/table_static.c    2016-01-11 10:16:15.486422024 +0100
> --- b/table_static.c    2016-01-08 12:58:58.564321019 +0100
> ***************
> *** 95,101 ****
> 
>       fp = fopen(config, "r");
>       if (fp == NULL)
> !         return 0;
> 
>       while ((flen = getline(&buf, &sz, fp)) != -1) {
>           if (buf[flen - 1] == '\n')
> --- 95,101 ----
> 
>       fp = fopen(config, "r");
>       if (fp == NULL)
> !         goto err;
> 
>       while ((flen = getline(&buf, &sz, fp)) != -1) {
>           if (buf[flen - 1] == '\n')
> ***************
> *** 143,148 ****
> --- 143,151 ----
>       free(buf);
>       fclose(fp);
>       return ret;
> + err:
> +         log_warn("warn: Table \"%s\"", config);
> +         return 0;
>   }
> 
>   static int
> 
> If someone could review it and test it before I fork the repository and make
> a merge request on github.

Some notes:

- Development happens in OpenBSD -current, so please diff against CVS.
- Please send unified diffs (not context output as above).
- I do not see the point of introducing a goto/label, just add the log
  message and return, also if check can be folded, like this:

if ((fp = fopen(config, "r") == NULL) {
        log_warn("warn: table \"%s\"", config);
        return 0;
}

> Thank you.
> 
> Regards,
> Alexis VACHETTE.
> 
> -- 
> You received this mail because you are subscribed to [email protected]
> To unsubscribe, send a mail to: [email protected]
> 

-- 
You received this mail because you are subscribed to [email protected]
To unsubscribe, send a mail to: [email protected]

Reply via email to