Compare commits

...
Author SHA1 Message Date
Marek Habersack 9fbea2d56a Second part of fix for bug #416620
svn path=/branches/mono-1-1-18/mcs/; revision=111126
2008-08-20 14:26:13 +00:00
Marek Habersack 6e5c0bdf9e Security fix for bug #418620
svn path=/branches/mono-1-1-18/mcs/; revision=111117
2008-08-20 13:17:53 +00:00
Marek Habersack 4f5502c48e Fix for CVE-2008-3422
svn path=/branches/mono-1-1-18/mcs/; revision=110142
2008-08-11 18:46:59 +00:00
Miguel de Icaza 8e924fbd43 Backport this patch here as well (from trunk/68776)
svn path=/branches/mono-1-1-18/mcs/; revision=68790
2006-12-01 00:50:23 +00:00
Miguel de Icaza 6ee1677924 Apply patch from Paolo:
2006-11-30  Paolo Molaro ([email protected])

        * metadata.c, marshal.c: locking fixes when writing to image->mempool.



svn path=/branches/mono-1-1-18/mono/; revision=68789
2006-12-01 00:42:07 +00:00
Wade Berrier 97263cd3ed version bump
svn path=/branches/mono-1-1-18/mono/; revision=66847
2006-10-20 22:06:28 +00:00
Miguel de Icaza 2b027d9141 On behalf of Martin: 2006-10-18 Martin Baulig <[email protected]>
* anonymous.cs: Propagate the IsStatic state, fixes the crasher in banshee.

svn path=/branches/mono-1-1-18/mcs/; revision=66812
2006-10-19 03:09:35 +00:00
Miguel de Icaza c83bb07067 Backport this fix
svn path=/branches/mono-1-1-18/mono/; revision=66810
2006-10-19 03:00:48 +00:00
23 changed files with 166 additions and 20 deletions

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ AC_CANONICAL_SYSTEM
m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(mono,1.1.18)
AM_INIT_AUTOMAKE(mono,1.1.18.1)
AM_MAINTAINER_MODE
AC_PROG_LN_S
@@ -1,3 +1,9 @@
2008-08-20 Marek Habersack <[email protected]>
* HttpRuntimeConfig.cs: implemented the undocumented (but
supported in .NET 1.1) option EnableHeaderChecking to support fix
for bug #416620
2006-08-15 Eyal Alalouf <[email protected]>
* WebConfigurationSettings.cs: Remove i#if TARGET_JVM since Grasshopper
supports Remtoing now.
@@ -55,7 +55,8 @@ namespace System.Web.Configuration
public int IdleTimeout = 20; // minutes
public bool Enable = true;
public string VersionHeader;
public bool EnableHeaderChecking = true;
/* Only the config. handler should create instances of this. Use GetInstance (context) */
public HttpRuntimeConfig (object p)
{
@@ -92,6 +93,7 @@ namespace System.Web.Configuration
RequireRootSaveAsPath = parent.RequireRootSaveAsPath;
IdleTimeout = parent.IdleTimeout;
Enable = parent.Enable;
EnableHeaderChecking = parent.EnableHeaderChecking;
}
}
}
@@ -1,3 +1,13 @@
2008-07-25 Dean Brettle <[email protected]>
* HtmlControl.cs (PreProcessRelativeReference),
HtmlForm.cs (RenderAttributes), HtmlInputButton (RenderAttributes),
HtmlInputRadioButton (RenderAttributes), HtmlSelect (RenderChildren):
Encode attributes that could contain HTML special chars.
* HtmlSelect (RenderChildren): HTML-encode option text.
* Fix for CVE-2008-3422
2006-09-18 Igor Zelmanovich <[email protected]>
* HtmlHead.cs:
@@ -90,7 +90,7 @@ namespace System.Web.UI.HtmlControls{
catch (Exception) {
throw new HttpException(attribName + " property had malformed url");
}
writer.WriteAttribute(attribName, attr);
writer.WriteAttribute(attribName, attr, true);
Attributes.Remove(attribName);
}
}
@@ -302,7 +302,7 @@ return true;
w.WriteAttribute ("name", Name);
w.WriteAttribute ("method", Method);
w.WriteAttribute ("action", action);
w.WriteAttribute ("action", action, true);
if (ID == null) {
/* If ID != null then HtmlControl will
@@ -181,7 +181,7 @@ namespace System.Web.UI.HtmlControls {
}
if (onclick.Length > 0) {
writer.WriteAttribute ("onclick", onclick);
writer.WriteAttribute ("onclick", onclick, true);
writer.WriteAttribute ("language", "javascript");
}
}
@@ -197,7 +197,7 @@ namespace System.Web.UI.HtmlControls {
if (oc != null) {
writer.WriteAttribute ("language", "javascript");
writer.WriteAttribute ("onclick", oc);
writer.WriteAttribute ("onclick", oc, true);
}
}
#endif
@@ -120,7 +120,7 @@ namespace System.Web.UI.HtmlControls {
protected override void RenderAttributes (HtmlTextWriter writer)
{
writer.WriteAttribute ("value", Value);
writer.WriteAttribute ("value", Value, true);
Attributes.Remove ("value");
base.RenderAttributes (writer);
}
@@ -665,10 +665,10 @@ namespace System.Web.UI.HtmlControls
}
}
w.WriteAttribute ("value", item.Value);
w.WriteAttribute ("value", item.Value, true);
w.Write (HtmlTextWriter.TagRightChar);
w.Write (item.Text);
w.Write (HttpUtility.HtmlEncode(item.Text));
w.WriteEndTag ("option");
w.WriteLine ();
@@ -1,3 +1,9 @@
2008-08-20 Marek Habersack <[email protected]>
* HttpResponseHeader.cs: encode header values if
httpRuntime.enableHeaderChecking is true (default). Fixes bug
#418620
2006-10-09 Marek Habersack <[email protected]>
* HttpApplication.cs: change the pipeline order for ASP.NET 2.0 to
@@ -923,8 +923,10 @@ namespace System.Web {
if (worker_request == null)
return String.Empty; // don't check security with an empty string!
if (physical_path == null)
physical_path = MapPath (CurrentExecutionFilePath);
if (physical_path == null) {
// Don't call HttpRequest.MapPath here, as that one *trims* the input
physical_path = worker_request.GetFilePathTranslated ();
}
if (SecurityManager.SecurityEnabled) {
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, physical_path).Demand ();
@@ -30,17 +30,65 @@
using System.Collections;
using System.Text;
using System.Web.Configuration;
namespace System.Web {
internal abstract class BaseResponseHeader {
public string Value;
string headerValue;
public string Value {
get { return headerValue; }
set { headerValue = EncodeHeader (value); }
}
static bool headerCheckingEnabled;
static BaseResponseHeader () {
#if NET_2_0
HttpRuntimeSection section = WebConfigurationManager.GetSection ("system.web/httpRuntime") as HttpRuntimeSection;
#else
HttpRuntimeConfig section = HttpContext.GetAppConfig ("system.web/httpRuntime") as HttpRuntimeConfig;
#endif
headerCheckingEnabled = section == null || section.EnableHeaderChecking;
}
internal BaseResponseHeader (string val)
{
Value = val;
}
string EncodeHeader (string value)
{
if (value == null || value.Length == 0)
return value;
if (headerCheckingEnabled) {
StringBuilder ret = new StringBuilder ();
int len = value.Length;
for (int i = 0; i < len; i++) {
switch (value [i]) {
case '\r':
ret.Append ("%0d");
break;
case '\n':
ret.Append ("%0a");
break;
default:
ret.Append (value [i]);
break;
}
}
return ret.ToString ();
} else
return value;
}
internal abstract void SendContent (HttpWorkerRequest wr);
}
@@ -1,3 +1,10 @@
2008-07-27 Dean Brettle <[email protected]>
* HtmlInputButtonTest.cs, HtmlImageTest.cs, HtmlFormTest.cs,
HtmlInputRadioButtonTest.cs, HtmlSelectTest.cs: Added tests
for HTML-encoded of attributes.
* Fix for CVE-2008-3422
2006-09-17 Igor Zelmanovich <[email protected]>
* HtmlAnchorTest.cs: added test for ViewState
@@ -118,13 +118,13 @@ namespace MonoTests.System.Web.UI.HtmlControls {
img.Alt = "*2*";
img.Border = 3;
img.Height = 4;
img.Src = "*5*";
img.Src = "*5<&*";
img.Width = 6;
Assert.AreEqual (6, img.Attributes.Count, "Attributes.Count");
HtmlTextWriter writer = img.GetWriter ();
Assert.AreEqual (" src=\"*5*\" align=\"*1*\" alt=\"*2*\" border=\"3\" height=\"4\" width=\"6\" /", writer.InnerWriter.ToString ());
Assert.AreEqual (" src=\"*5&lt;&amp;*\" align=\"*1*\" alt=\"*2*\" border=\"3\" height=\"4\" width=\"6\" /", writer.InnerWriter.ToString ());
}
}
}
@@ -164,6 +164,28 @@ namespace MonoTests.System.Web.UI.HtmlControls {
Assert.IsTrue (found >= 0, "#02");
}
[Test]
public void OnClickAttributeWithSpecials ()
{
StringWriter sw = new StringWriter ();
HtmlTextWriter tw = new HtmlTextWriter (sw);
HtmlInputButtonPoker p = new HtmlInputButtonPoker ();
p.Page = new Page ();
p.Attributes["onclick"] = "alert('<&');";
p.DoRenderAttributes (tw);
string str = sw.ToString ();
int found = str.IndexOf ("alert('&lt;&amp;');");
Assert.IsTrue (found >= 0, "#01");
p.ServerClick += new EventHandler (EmptyHandler);
sw = new StringWriter ();
tw = new HtmlTextWriter (sw);
p.DoRenderAttributes (tw);
str = sw.ToString ();
found = str.IndexOf ("alert('&lt;&amp;');");
Assert.IsTrue (found >= 0, "#02" + str);
}
private static void EmptyHandler (object sender, EventArgs e)
{
}
@@ -236,9 +236,9 @@ namespace MonoTests.System.Web.UI.HtmlControls {
rb.ID = "id";
string attrs = rb.RenderAttributes ();
Assert.IsTrue (attrs.IndexOf ("value=\"id\"") >= 0);
rb.Value = "hola";
rb.Value = "hola<&";
attrs = rb.RenderAttributes ();
Assert.IsTrue (attrs.IndexOf ("value=\"hola\"") >= 0);
Assert.IsTrue (attrs.IndexOf ("value=\"hola&lt;&amp;\"") >= 0);
}
#if NET_2_0
@@ -478,5 +478,17 @@ namespace MonoTests.System.Web.UI.HtmlControls {
Assert.AreEqual (exp, s.Render ());
}
[Test]
public void HtmlEncodeValues ()
{
TestHtmlSelect s = new TestHtmlSelect ();
s.DataSource = new string [] { "&", "<" };
s.DataBind ();
string exp = @"<select name>
<option value=""&amp;"">&amp;</option>
<option value=""&lt;"">&lt;</option>
</select>";
HtmlDiff.AssertAreEqual (exp, s.Render (), "HtmlEncodeValues");
}
}
}
+4
View File
@@ -1,3 +1,7 @@
2006-10-18 Martin Baulig <[email protected]>
* anonymous.cs: Propagate the IsStatic state, fixes the crasher in banshee.
2006-10-12 Martin Baulig <[email protected]>
* anonymous.cs
+1
View File
@@ -1232,6 +1232,7 @@ namespace Mono.CSharp {
aec.CurrentAnonymousMethod = this;
aec.IsFieldInitializer = ec.IsFieldInitializer;
aec.IsStatic = ec.IsStatic;
Report.Debug (64, "RESOLVE ANONYMOUS METHOD #1", this, Location, ec, aec,
RootScope, Parameters, Block);
+4
View File
@@ -1,3 +1,7 @@
2006-10-18 Miguel de Icaza <[email protected]>
* io-portability.c (find_in_dir): First string dup, then closedir.
2006-10-12 Dick Porter <[email protected]>
* processes.c (_wapi_process_reap): Unref a process handle if we
+5 -2
View File
@@ -88,13 +88,16 @@ static gchar *find_in_dir (DIR *current, const gchar *name)
#endif
if (!g_ascii_strcasecmp (name, entry->d_name)) {
char *ret;
#ifdef DEBUG
g_message ("%s: matched [%s] to [%s]\n", __func__,
entry->d_name, name);
#endif
ret = g_strdup (entry->d_name);
closedir (current);
return(g_strdup (entry->d_name));
return ret;
}
}
+2
View File
@@ -1014,6 +1014,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
mp = mb->method->klass->image->mempool;
mono_loader_lock ();
if (mb->dynamic) {
method = mb->method;
@@ -1086,6 +1087,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
printf ("%s\n", mono_disasm_code (&marshal_dh, method, mb->code, mb->code + mb->pos));
#endif
mono_loader_unlock ();
return method;
}
+19 -2
View File
@@ -1490,6 +1490,7 @@ mono_metadata_parse_type_full (MonoImage *m, MonoGenericContainer *container, Mo
int count = 0;
gboolean found;
mono_loader_lock ();
/*
* According to the spec, custom modifiers should come before the byref
* flag, but the IL produced by ilasm from the following signature:
@@ -1561,6 +1562,7 @@ mono_metadata_parse_type_full (MonoImage *m, MonoGenericContainer *container, Mo
if (!do_mono_metadata_parse_type (type, m, container, ptr, &ptr)) {
if (type != &stype)
g_free (type);
mono_loader_unlock ();
return NULL;
}
@@ -1590,12 +1592,16 @@ mono_metadata_parse_type_full (MonoImage *m, MonoGenericContainer *container, Mo
LOCKING: even though we don't explicitly hold a lock, in the problematic case 'ret' is a field
of a MonoClass which currently holds the loader lock. 'type' is local.
*/
if (ret->data.klass == type->data.klass)
if (ret->data.klass == type->data.klass) {
mono_loader_unlock ();
return ret;
}
}
/* No need to use locking since nobody is modifying the hash table */
if ((cached = g_hash_table_lookup (type_cache, type)))
if ((cached = g_hash_table_lookup (type_cache, type))) {
mono_loader_unlock ();
return cached;
}
}
/* printf ("%x %x %c %s\n", type->attrs, type->num_mods, type->pinned ? 'p' : ' ', mono_type_full_name (type)); */
@@ -1604,6 +1610,7 @@ mono_metadata_parse_type_full (MonoImage *m, MonoGenericContainer *container, Mo
type = mono_mempool_alloc (m->mempool, sizeof (MonoType));
memcpy (type, &stype, sizeof (MonoType));
}
mono_loader_unlock ();
return type;
}
@@ -1716,9 +1723,11 @@ mono_metadata_signature_alloc (MonoImage *m, guint32 nparams)
{
MonoMethodSignature *sig;
mono_loader_lock ();
sig = mono_mempool_alloc0 (m->mempool, sizeof (MonoMethodSignature) + ((gint32)nparams - MONO_ZERO_LEN_ARRAY) * sizeof (MonoType*));
sig->param_count = nparams;
sig->sentinelpos = -1;
mono_loader_unlock ();
return sig;
}
@@ -2389,6 +2398,7 @@ mono_metadata_parse_mh_full (MonoImage *m, MonoGenericContainer *container, cons
g_return_val_if_fail (ptr != NULL, NULL);
mono_loader_lock ();
switch (format) {
case METHOD_HEADER_TINY_FORMAT:
mh = mono_mempool_alloc0 (m->mempool, sizeof (MonoMethodHeader));
@@ -2397,6 +2407,7 @@ mono_metadata_parse_mh_full (MonoImage *m, MonoGenericContainer *container, cons
local_var_sig_tok = 0;
mh->code_size = flags >> 2;
mh->code = ptr;
mono_loader_unlock ();
return mh;
case METHOD_HEADER_TINY_FORMAT1:
mh = mono_mempool_alloc0 (m->mempool, sizeof (MonoMethodHeader));
@@ -2410,6 +2421,7 @@ mono_metadata_parse_mh_full (MonoImage *m, MonoGenericContainer *container, cons
*/
mh->code_size = flags >> 2;
mh->code = ptr;
mono_loader_unlock ();
return mh;
case METHOD_HEADER_FAT_FORMAT:
fat_flags = read16 (ptr);
@@ -2438,6 +2450,7 @@ mono_metadata_parse_mh_full (MonoImage *m, MonoGenericContainer *container, cons
ptr = code + code_size;
break;
default:
mono_loader_unlock ();
return NULL;
}
@@ -2460,6 +2473,7 @@ mono_metadata_parse_mh_full (MonoImage *m, MonoGenericContainer *container, cons
mh->locals [i] = mono_metadata_parse_type_full (
m, container, MONO_PARSE_LOCAL, 0, locals_ptr, &locals_ptr);
if (!mh->locals [i]) {
mono_loader_unlock ();
return NULL;
}
}
@@ -2472,6 +2486,7 @@ mono_metadata_parse_mh_full (MonoImage *m, MonoGenericContainer *container, cons
mh->init_locals = init_locals;
if (fat_flags & METHOD_HEADER_MORE_SECTS)
parse_section_data (m, mh, (const unsigned char*)ptr);
mono_loader_unlock ();
return mh;
}
@@ -2924,7 +2939,9 @@ mono_metadata_interfaces_from_typedef_full (MonoImage *meta, guint32 index, Mono
++pos;
}
mono_loader_lock ();
result = mono_mempool_alloc0 (meta->mempool, sizeof (MonoClass*) * (pos - start));
mono_loader_unlock ();
pos = start;
while (pos < tdef->rows) {