Closed Bug 276913 Opened 20 years ago Closed 20 years ago

Uninitialized value message from CGI.pl line 176

Categories

(Bugzilla :: Bugzilla-General, defect)

2.19.1
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 2.18

People

(Reporter: mkanat, Assigned: LpSolit)

References

Details

Attachments

(2 files, 1 obsolete file)

I see a lot of this in landfill's error_log for Apache:

[Sun Jan 02 18:59:34 2005] [error] [client 202.22.158.65] [Sun Jan  2 18:59:34
2005] show_bug.cgi: Use of uninitialized value in string eq at CGI.pl line 176.,
referer:
http://landfill.bugzilla.org/bugzilla-tip/buglist.cgi?query_format=specific&order=relevance+desc&bug_status=__open__&product=&content=

The line is:

return if ($field eq "dependson" || $field eq "blocked");

It just needs to check for the actual *existence* of $field.
This was introduced by bug 264601, according to cvs blame.
The actually correct way to fix this bug is to set a default for $field when it
isn't passed. I'm assuming that developers are assuming bug_id when they don't
pass a field name.

I could also put "unknown."
I have a patch for this too. I wrote it just before 31. December. That's the
reason why this patch and some others have not been uploaded yet.

I will submit in a few minutes. Taking bug!
Assignee: mkanat → LpSolit
Attached patch Simple patch (obsolete) — Splinter Review
OK, here's a very simple patch to solve this problem. Anybody may do the review
if they want, but lpsolit wrote the original code, so I wanted him to look at
it.

By the way, this code is *really* confusing. I had to actually go look at the
user-error template to understand what $field was being used for.
Attachment #170178 - Flags: review?(LpSolit)
Oh, OK. You can upload your patch, also. :-)
Flags: blocking2.20?
Flags: approval2.18?
I tried to clear approval2.18? but it won't let me, even though I'm the one who
set it.
Flags: blocking2.18?
Flags: approval2.18?
Attachment #170180 - Flags: review?(mkanat)
Comment on attachment 170180 [details] [diff] [review]
Check if $field is defined

>-    return if ($field eq "dependson" || $field eq "blocked");
>+    return if (defined $field && ($field eq "dependson" || $field eq "blocked"));

  If you could change that to defined($field) on checkin I'd be happy.
Otherwise this is fine.
Attachment #170180 - Flags: review?(mkanat) → review+
Attachment #170178 - Flags: review?(LpSolit)
OK, *now* I'm asking for approval.
Flags: approval?
Flags: approval2.18?
(In reply to comment #8)
>   If you could change that to defined($field) on checkin I'd be happy.

Not sure this is really necessary. Too many () aren't good. ;)
Status: NEW → ASSIGNED
(In reply to comment #10)
> Not sure this is really necessary. Too many () aren't good. ;)

  I fully disagree. Read the perlstyle manual. (And every other
programming-style manual in existence.)
Whiteboard: patch awaiting approval
Not that Max nee(In reply to comment #11)
> (In reply to comment #10)
> > Too many () aren't good. ;)
>  I fully disagree.

Not that Max needs my help, but he's right. Explicitly stating your wishes (in 
this case, by wrapping your code in () ) is far better than hoping that the 
compiler -- and every future compiler -- does things the way you want it to be 
done.

Also remember, you won't be maintaining this code forever, or even necessarily 
next month. We owe it to the future guys who have to read/decipher it to make 
things as clear as possible.
Flags: blocking2.20?
Flags: blocking2.20+
Flags: blocking2.18?
Flags: blocking2.18+
Flags: approval?
Flags: approval2.18?
Flags: approval2.18+
Flags: approval+
Target Milestone: --- → Bugzilla 2.18
Whiteboard: patch awaiting approval → patch awaiting checkin
Attachment #170178 - Attachment is obsolete: true
The line following my patch differs between 2.18 and 2.19.1 so I need to write
the same patch for the 2.18 branch.

For consistency with my already approved patch, I don't add () around $field.
Attachment #170479 - Flags: review?(mkanat)
Comment on attachment 170479 [details] [diff] [review]
backport for the 2.18 branch

Yes, I cetify that this patch is the same as the one above. :-)
Attachment #170479 - Flags: review?(mkanat) → review+
2.18:
Checking in CGI.pl;
/cvsroot/mozilla/webtools/bugzilla/CGI.pl,v  <--  CGI.pl
new revision: 1.211.2.5; previous revision: 1.211.2.4
done

Tip:
Checking in CGI.pl;
/cvsroot/mozilla/webtools/bugzilla/CGI.pl,v  <--  CGI.pl
new revision: 1.219; previous revision: 1.218
done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Whiteboard: patch awaiting checkin
*** Bug 281013 has been marked as a duplicate of this bug. ***
Whiteboard: [applied to b.m.o]
Whiteboard: [applied to b.m.o]
QA Contact: matty_is_a_geek → default-qa
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: