View Issue Details

IDProjectCategoryView StatusLast Update
0017967mantisbtbugtrackerpublic2015-01-25 18:17
Reporterinfo4km Assigned Todregad  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version1.2.18 
Target Version1.2.19Fixed in Version1.2.19 
Summary0017967: Reporting an issue gives: 'Invalid argument supplied for foreach()' in '/opt/mantisbt-1.2.18/core/gpc_api.php' line 259
Description

When reporting an issue I get the following system warning:

'Invalid argument supplied for foreach()' in '/opt/mantisbt-1.2.18/core/gpc_api.php' line 259

TagsNo tags attached.
Attached Files
Error_Bug Tracker_php.html (6,853 bytes)   
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<link rel="stylesheet" type="text/css" href="https://bugtracker.company.com/css/default.css" />
	<script type="text/javascript"><!--
		if(document.layers) {document.write("<style>td{padding:0px;}<\/style>")}
	// --></script>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Cache-Control" content="no-cache" />
	<meta http-equiv="Pragma-directive" content="no-cache" />
	<meta http-equiv="Cache-Directive" content="no-cache" />
	<meta http-equiv="Expires" content="Wed, 17 Dec 2014 21:26:30 GMT" />
	<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon" />
	<link rel="search" type="application/opensearchdescription+xml" title="MantisBT: Text Search" href="https://bugtracker.company.com/browser_search_plugin.php?type=text" />	<link rel="search" type="application/opensearchdescription+xml" title="MantisBT: Issue Id" href="https://bugtracker.company.com/browser_search_plugin.php?type=id" />	<title>Bug Tracker</title>
<script type="text/javascript" src="/javascript/min/common.js"></script>
<script type="text/javascript">var loading_lang = "Loading...";</script><script type="text/javascript" src="/javascript/min/ajax.js"></script>
</head>
<body>
<div align="left"><a href="my_view_page.php"><img border="0" alt="Bug Tracker" src="/images/mantis_logo.gif" /></a></div><table class="hide"><tr><td class="login-info-left">Logged in as: <span class="italic">km</span> <span class="small">(KM - administrator)</span></td><td class="login-info-middle"><span class="italic">12-17-14 16:26 EST</span></td><td class="login-info-right"><form method="post" name="form_set_project" action="/set_project.php">Project: <select name="project_id" class="small" onchange="document.forms.form_set_project.submit();"><option value="0">All Projects</option>
<option value="31">Device Integration</option>
<option value="38">Our log proj</option>
<option value="49">Our log proj Customer Defects</option>
<option value="48">Our log proj Customer Enhancements</option>
<option value="50">Our log proj Device Integration</option>
<option value="42">Tools</option>
<option value="19">Our Proj 4.1</option>
<option value="34">Our Proj 4.1.1</option>
<option value="37">Our Proj 4.1.2</option>
<option value="43">Our Proj 4.1.3</option>
<option value="44">Our Proj 4.1.4</option>
<option value="35" selected="selected" >Our Proj 4.2</option>
<option value="39">ProjTest</option>
<option value="53">Our Proj 4.3</option>
<option value="51">Our Proj 5.0</option>
<option value="52">Our Proj 5.1</option>
<option value="47">Our Proj Customer Defects</option>
<option value="46">Our Proj Customer Enhancements</option>
<option value="41">Our Proj Deferred</option>
</select> <input type="submit" class="button-small" value="Switch" /></form><a href="https://bugtracker.company.com/issues_rss.php?username=km&amp;key=2ef8a2cae503ad48c3120cc9ee0b61ca&amp;project_id=35"><img src="/images/rss.png" alt="RSS" style="border-style: none; margin: 5px; vertical-align: middle;" /></a></td></tr></table><table class="width100" cellspacing="0"><tr><td class="menu"><a href="/my_view_page.php">My View</a> | <a href="/view_all_bug_page.php">View Issues</a> | <a href="/bug_report_page.php">Report Issue</a> | <a href="/changelog_page.php">Change Log</a> | <a href="/roadmap_page.php">Roadmap</a> | <a href="/summary_page.php">Summary</a> | <a href="/manage_overview_page.php">Manage</a> | <a href="/account_page.php">My Account</a> | <a href="/logout_page.php">Logout</a></td><td class="menu right nowrap"><form method="post" action="/jump_to_bug.php"><input type="text" name="bug_id" size="10" class="small" value="Issue #" onfocus="if (this.value == 'Issue #') this.value = ''" onblur="if (this.value == '') this.value = 'Issue #'" />&#160;<input type="submit" class="button-small" value="Jump" />&#160;</form></td></tr></table><br /><div align="center"><table class="width50" cellspacing="1"><tr><td class="form-title">SYSTEM WARNING</td></tr><tr><td><p class="center" style="color:red">'Invalid argument supplied for foreach()' in '/opt/mantisbt-1.2.18/core/gpc_api.php' line 259</p></td></tr><tr><td><p class="center">Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.</p></td></tr><tr><td>		<center>
			<table class="width75">
				<tr>
					<td>Full path: /opt/mantisbt-1.2.18/core/gpc_api.php</td>
				</tr>
				<tr>
					<td>Line: 259</td>
				</tr>
				<tr>
					<td>
						<table class="width100"><tr><th>Variable</th><th>Value</th><th>Type</th></tr><tr><td>p_var_name</td><td>custom_field_3</td><td>string</td></tr>
<tr><td>p_default</td><td></td><td>NULL</td></tr>
<tr><td>t_result</td><td></td><td>NULL</td></tr>
<tr><td colspan="3" align="left"><br /><strong>args</strong></td></tr><tr><td colspan="3"><table class="width100"><tr><th>Variable</th><th>Value</th><th>Type</th></tr><tr><td>0</td><td>custom_field_3</td><td>string</td></tr>
<tr><td>1</td><td></td><td>NULL</td></tr>
</table></td></tr><tr><td colspan="3" align="left"><br /><strong>t_array</strong></td></tr><tr><td colspan="3"><table class="width100"><tr><th>Variable</th><th>Value</th><th>Type</th></tr></table></td></tr></table>					</td>
				</tr>
			</table>
		</center>
</td></tr><tr><td><center><table class="width75"><tr><th>Filename</th><th>Line</th><th></th><th></th><th>Function</th><th>Args</th></tr><tr class="row-1"><td>/opt/mantisbt-1.2.18/core/gpc_api.php</td><td>212</td><td>-</td><td>-</td><td>gpc_get_string_array</td><td>( &lt;string&gt;'custom_field_3', &lt;NULL&gt;NULL )</td></tr><tr class="row-2"><td>/opt/mantisbt-1.2.18/bug_report.php</td><td>134</td><td>-</td><td>-</td><td>gpc_get_custom_field</td><td>( &lt;string&gt;'custom_field_3', &lt;string&gt;'5', &lt;NULL&gt;NULL )</td></tr></table></center></td></tr></table></div>	<br />
	<hr size="1" />
<table border="0" width="100%" cellspacing="0" cellpadding="0"><tr valign="top"><td>	<span class="timer"><a href="http://www.mantisbt.org/" title="Free Web-Based Bug Tracker">MantisBT 1.2.18</a> [<a href="http://www.mantisbt.org/" title="Free Web-Based Bug Tracker" target="_blank">^</a>]</span>
	<address>Copyright &copy; 2000 - 2014 MantisBT Team</address>
	<address><a href="mailto:km@company.com">km@company.com</a></address>
</td><td>
	<div align="right"><a href="http://www.mantisbt.org" title="Free Web Based Bug Tracker"><img src="/images/mantis_logo.png" width="145" height="50" alt="Powered by Mantis Bugtracker" border="0" /></a></div>
</td></tr></table>
</body>
</html>
Error_Bug Tracker_php.html (6,853 bytes)   
customfield_1.jpg (51,368 bytes)   
customfield_1.jpg (51,368 bytes)   
customfield_2.jpg (48,756 bytes)   
customfield_2.jpg (48,756 bytes)   

Relationships

related to 0017640 closeddregad CVE-2014-6387: Null byte poisoning in LDAP authentication 

Activities

info4km

info4km

2014-12-15 11:44

reporter   ~0042024

Last edited: 2014-12-16 11:43

I just upgraded from 1.2.17 to 1.2.18

(for now I have turned off these warnings by setting:
$g_display_errors[E_WARNING] = DISPLAY_ERROR_NONE;

as explained in issue 0017322, but I don't like that solution.

dregad

dregad

2014-12-16 11:48

developer   ~0042031

I was not able to reproduce your problem. Please provide additional information to help understanding the problem. Please follow these steps:

  1. temporarily configure your system as follows:

$g_display_errors[E_WARNING] = 'halt';
$g_show_detailed_errors = ON;

WARNING - SECURITY RISK: the 'show_detailed_errors' config can cause MantisBT to display sensitive information about your system. We recommend to restrict its activation to a Test environment, only for as long as necessary. If possible, do not turn it ON globally, instead limit it for specific user(s) using the Manage Configuration page.

  1. Reproduce the error
  2. save the output of the error screen, preferably as an HTML page
  3. be careful to remove/mask any confidential information if needed
  4. upload the results here
info4km

info4km

2014-12-17 16:41

reporter   ~0042032

OK - I followed the instructions in your note. The page I have uploaded does not look exactly as it did. When I edited the confidential stuff it got slightly messed up. All of the info that I saw is there though. See attached file Error_BugTracker_php.html.

dregad

dregad

2014-12-18 11:51

developer   ~0042036

I'm still not able to reproduce. It appears the problem occurs on a custom field of type checkbox, can you detail how it is defined ?

info4km

info4km

2014-12-18 12:33

reporter   ~0042037

I have attached two images of the custom fields that are check boxes. It's weird because I think I had trouble with these fields when I first converted to 1.2.x in the first place. Now they are finally working, and they are giving us trouble again. Images are customfield_1.jpg and customfield_2.jpg.

If its a checkbox config issue I can make it a List with a yes|no that defaults to no.

dregad

dregad

2014-12-18 18:25

developer   ~0042038

I tried with a CF with same settings as you uploaded, but it works fine for me.

According to the detailed error log you sent earlier, the custom field's name is 'custom_field_3' which does not match the field names in the 2 screenshots.

info4km

info4km

2014-12-19 08:58

reporter   ~0042043

There is no field with that name. The DB shows that custom field with an ID of 3 is "Documentation Required" which is one of the screen shots I've attached.

info4km

info4km

2014-12-19 09:04

reporter   ~0042044

FYI - I made that checkbox a List with no|yes - and set the debugging again. I get the same results but for custom_field_2 which is the other checkbox. Maybe

If no solution is found, I will change them to lists.

dregad

dregad

2014-12-21 11:26

developer   ~0042045

Last edited: 2014-12-21 11:30

I can reproduce the behavior now. According to git bisect, it is a regression introduced by commit 215968fa8ff33e327f0600765a5caa24de392cbc (see 0017640).

Related Changesets

MantisBT: master-1.2.x 215968fa

2013-10-12 13:58

Paul Richards

Committer: dregad


Details Diff
Strip null bytes out of GPC input strings

Backporting commit fc02c46eea9d9e7cc472a7fc1801ea65d467db76 from master
branch to fix issue 0017640

Signed-off-by: Damien Regad <dregad@mantisbt.org>
Affected Issues
0017640, 0017967, 0017977
mod - core/gpc_api.php Diff File

MantisBT: master-1.2.x 99ada4de

2014-12-21 06:46

dregad


Details Diff
Fix system warning in gpc_get_string_array()

The fix for issue 0017640 did not consider that the value returned by
gpc_get() is not necessarily an array - it can be the default value
(e.g. null) causing PHP to throw an 'Invalid argument supplied for
foreach()' warning.

Fixes 0017967, regression from 215968fa8ff33e327f0600765a5caa24de392cbc
Affected Issues
0017640, 0017967
mod - core/gpc_api.php Diff File

MantisBT: master 61c8548c

2014-12-21 06:46

dregad


Details Diff
Fix system warning in gpc_get_string_array()

The fix for issue 0017640 did not consider that the value returned by
gpc_get() is not necessarily an array - it can be the default value
(e.g. null) causing PHP to throw an 'Invalid argument supplied for
foreach()' warning.

Fixes 0017967 (ported from 1.2.x)
Affected Issues
0017640, 0017967
mod - core/gpc_api.php Diff File