[Mono-bugs] [Bug 523356] New: Unhandled Exception: System.ArgumentException: Arg_InsufficientSpace in System.Text.UTF8Encoding.InternalGetChars

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Jul 19 08:14:16 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=523356


           Summary: Unhandled Exception: System.ArgumentException:
                    Arg_InsufficientSpace in
                    System.Text.UTF8Encoding.InternalGetChars
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.0.x
          Platform: x86
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: scdeimos+novell.com at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.11)
Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11

Using, System.DirectoryServices, which in Linux is a wrapper around
Novell.Directory.Ldap, inetOrgPerson.jpegPhoto attributes cannot be queried
when their source file binary size exceeds 811 bytes.

jpegPhoto attributes whose source file binary size is 811 bytes or less can be
returned successfully, but those whose source file binary size is 812 bytes or
greater cause the following exception:

Unhandled Exception: System.ArgumentException: Arg_InsufficientSpace
Parameter name: chars
  at System.Text.UTF8Encoding.InternalGetChars (System.Byte* bytes, Int32
byteCount, System.Char* chars, Int32 charCount, System.UInt32& leftOverBits,
System.UInt32& leftOverCount, System.Object provider,
System.Text.DecoderFallbackBuffer& fallbackBuffer, System.Byte[]& bufferArg,
Boolean flush) [0x00000] 
  at System.Text.UTF8Encoding.InternalGetChars (System.Byte[] bytes, Int32
byteIndex, Int32 byteCount, System.Char[] chars, Int32 charIndex,
System.UInt32& leftOverBits, System.UInt32& leftOverCount, System.Object
provider, System.Text.DecoderFallbackBuffer& fallbackBuffer, System.Byte[]&
bufferArg, Boolean flush) [0x00000] 
  at System.Text.UTF8Encoding.GetChars (System.Byte[] bytes, Int32 byteIndex,
Int32 byteCount, System.Char[] chars, Int32 charIndex) [0x00000] 
  at System.Text.Encoding.GetChars (System.Byte[] bytes) [0x00000] 
  at Novell.Directory.Ldap.LdapAttribute.get_StringValueArray () [0x00000] 
  at System.DirectoryServices.DirectorySearcher.DoSearch () [0x00000] 
  at System.DirectoryServices.DirectorySearcher.get_SrchColl () [0x00000] 
  at System.DirectoryServices.DirectorySearcher.FindAll () [0x00000] 
  at (wrapper remoting-invoke-with-check)
System.DirectoryServices.DirectorySearcher:FindAll ()
  at Framework.Utils.DoLookup (System.String ldapPath, System.String
ldapFilter) [0x00089]...


Reproducible: Always

Steps to Reproduce:
1. Create a new Windows Forms project (.NET 2.0 framework).

2. Add a Utils class whose code is the following:

using System;
using System.DirectoryServices;
using System.Windows.Forms;

namespace Framework
{
    public class Utils
    {
        public Utils()
        {
        }

        public static void SearchUsers(string ldapPath)
        {
            string ldapFilter = "(objectClass=person)";
            string lookupResult = DoLookup(ldapPath, ldapFilter);
            MessageBox.Show(lookupResult);
        }

        protected static string DoLookup(string ldapPath, string ldapFilter)
        {
            string finalResult = "";

            DirectoryEntry adFolderObject = new DirectoryEntry(ldapPath);

            DirectorySearcher adSearcherObject = new
DirectorySearcher(adFolderObject);
            adSearcherObject.SearchScope = SearchScope.OneLevel;
            adSearcherObject.SearchScope = SearchScope.Subtree;
            adSearcherObject.PropertiesToLoad.Clear();
            adSearcherObject.PropertiesToLoad.Add("dn");
            adSearcherObject.PropertiesToLoad.Add("cn");
            adSearcherObject.PropertiesToLoad.Add("ou");
            adSearcherObject.PropertiesToLoad.Add("mail");
            adSearcherObject.PropertiesToLoad.Add("jpegPhoto");
            adSearcherObject.Filter = ldapFilter;

            SearchResultCollection adSearchCollection =
adSearcherObject.FindAll();
            foreach (SearchResult adObject in adSearchCollection)
            {
                foreach (string propertyName in
adObject.Properties.PropertyNames)
                {
                    finalResult += propertyName + ":";
                    foreach (Object propertyValue in
adObject.Properties[propertyName])
                    {
                        string propValue = propertyValue.ToString();
                        if (propertyName.Equals("jpegPhoto",
StringComparison.OrdinalIgnoreCase)) {
                            finalResult += string.Format("    -- length {0}
--\n", propValue.Length);
                        } else {
                            finalResult += "    \"" + propertyValue.ToString()
+ "\"\n";
                        }
                    }
                    finalResult += (adObject.Properties.Count > 0) ? "" : "\n";
                }
                finalResult += "\n\n";
            }
            finalResult += "--end--";
            return finalResult;
        }

    }
}

3. Add a Form1.OnShow handler (for example) whose code contains:
    Utils.SearchUsers("ldap://127.0.0.1/dc=foo,dc=bar,dc=baz");
    Close();

[Change the LDAP path as appropriate.]

4. Use an LDAP administration tool (such as LAT, LUMA, GC or anything that can
handle inetOrgPerson.jpegPhoto attributes) to add a jpegPhoto to one of your
contacts or users contained in the ldap:// path you specified above, preferably
one much greater than 811 bytes (such as a more normal 8k).

5. Compile and run your project. It will bomb.
Actual Results:  
Exception thrown as noted above in Summary/Details.

Expected Results:  
The jpegPhoto attribute should be able to be queried without causing an
exception, regardless of how big it is.



Ubuntu 9.04 - the Jaunty Jackalope

Installed versions from gacutil --list:
=======================================
Novell.Directory.Ldap, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=0738eb9f132ed756
Novell.Directory.Ldap, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=0738eb9f132ed756
System.DirectoryServices, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a
System.DirectoryServices, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a

LDAP inetOrgPerson References:
==============================
RFC2798 - Definition of the inetOrgPerson LDAP Object Class, section 2.6 JPEG
Photograph
RFC2252 - Lightweight Directory Access Protocol (v3): Attribute, section 4.3.2.
Syntax Object Identifiers, identifier 1.3.6.1.4.1.1466.115.121.1.28

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list