You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by Mark Martinec <Ma...@ijs.si> on 2010/06/01 21:29:01 UTC
trivial fix to: Use of uninitialized value $opt{"syslog-socket"} in lc
Here's one trivial fix I committed to 3.3 and to trunk to avoid a warning
when starting spamd:
warn: Use of uninitialized value $opt{"syslog-socket"} in lc at /usr/local/bin/spamd line 444.
It's a trivial one, not worth making a fuss about in bugzilla,
I just wanted to let you know what it's all about:
--- spamd/spamd.raw (revision 950094)
+++ spamd/spamd.raw (working copy)
@@ -443,10 +443,12 @@
# socket of 'none' means as much as --syslog=null. Sounds complicated? It is.
# But it works.
# )
-my $log_socket = lc($opt{'syslog-socket'});
+my $log_socket = $opt{'syslog-socket'};
if (!defined $log_socket || $log_socket eq '') {
$log_socket = am_running_on_windows() ? 'none' : 'unix';
+} else {
+ $log_socket = lc $log_socket;
}
# This is the default log file; it can be changed on the command line
Mark
Re: trivial fix to: Use of uninitialized value $opt{"syslog-socket"} in lc
Posted by Mark Martinec <Ma...@ijs.si>.
> I would suggest ...
> $log_socket = $log_socket || '';
It is bad practice to treat user input as perl booleans.
For example, it would replace a log file name "0" with an empty string.
There were numerous cases of this already weeded out with 3.3
(but some are still there). Some of these cases even have
their own bugzilla entries, like bugs 5965, 6184, 6360.
Mark
Re: trivial fix to: Use of uninitialized value
$opt{"syslog-socket"} in lc
Posted by Karsten Bräckelmann <gu...@rudersport.de>.
On Tue, 2010-06-01 at 15:21 -0500, Todd Rinaldo wrote:
> > -my $log_socket = lc($opt{'syslog-socket'});
> > +my $log_socket = $opt{'syslog-socket'};
> >
> > if (!defined $log_socket || $log_socket eq '') {
> > $log_socket = am_running_on_windows() ? 'none' : 'unix';
> > +} else {
> > + $log_socket = lc $log_socket;
> > }
> This will actually cause warnings under perl 5.12, since perl 5.12 now
> warns you that undef was passed to lc.
That's exactly what the patch prevents, moving the lc() in the else
block that only gets evaluated if $log_socket is defined and not an
empty string.
> It'll still return an empty string but may cause allot of warnings.
> These warnings have just been cleaned out of the 3.3 branch, so I
> hate to see one go back in. I would suggest ...
>
> $log_socket = $log_socket || '';
>
> instead of
>
> $log_socket = lc $log_socket;
>
> It's more explicit about what you're trying to do anyway. In fact, not
> knowing the code, 0 might be a better choice than an empty string?
--
char *t="\10pse\0r\0dtu\0.@ghno\x4e\xc8\x79\xf4\xab\x51\x8a\x10\xf4\xf4\xc4";
main(){ char h,m=h=*t++,*x=t+2*h,c,i,l=*x,s=0; for (i=0;i<l;i++){ i%8? c<<=1:
(c=*++x); c&128 && (s+=h); if (!(h>>=1)||!t[s+h]){ putchar(t[s]);h=m;s=0; }}}
Re: trivial fix to: Use of uninitialized value $opt{"syslog-socket"} in lc
Posted by Todd Rinaldo <to...@cpanel.net>.
On Jun 1, 2010, at 2:29 PM, Mark Martinec wrote:
> Here's one trivial fix I committed to 3.3 and to trunk to avoid a warning
> when starting spamd:
> warn: Use of uninitialized value $opt{"syslog-socket"} in lc at /usr/local/bin/spamd line 444.
>
> It's a trivial one, not worth making a fuss about in bugzilla,
> I just wanted to let you know what it's all about:
>
>
> --- spamd/spamd.raw (revision 950094)
> +++ spamd/spamd.raw (working copy)
> @@ -443,10 +443,12 @@
> # socket of 'none' means as much as --syslog=null. Sounds complicated? It is.
> # But it works.
> # )
> -my $log_socket = lc($opt{'syslog-socket'});
> +my $log_socket = $opt{'syslog-socket'};
>
> if (!defined $log_socket || $log_socket eq '') {
> $log_socket = am_running_on_windows() ? 'none' : 'unix';
> +} else {
> + $log_socket = lc $log_socket;
> }
>
> # This is the default log file; it can be changed on the command line
>
>
>
> Mark
This will actually cause warnings under perl 5.12, since perl 5.12 now warns you that undef was passed to lc. It'll still return an empty string but may cause allot of warnings. These warnings have just been cleaned out of the 3.3 branch, so I hate to see one go back in. I would suggest ...
$log_socket = $log_socket || '';
instead of
$log_socket = lc $log_socket;
It's more explicit about what you're trying to do anyway. In fact, not knowing the code, 0 might be a better choice than an empty string?
Todd