Closed
Bug 119380
Opened 23 years ago
Closed 22 years ago
nsILDAPMessage needs to support binary attribute values
Categories
(Directory :: LDAP XPCOM SDK, defect, P1)
Directory
LDAP XPCOM SDK
Tracking
(Not tracked)
VERIFIED
FIXED
mozilla1.0.1
People
(Reporter: dmosedale, Assigned: dmosedale)
References
Details
(Whiteboard: [adt1 rtm])
Attachments
(2 files, 9 obsolete files)
8.24 KB,
patch
|
KaiE
:
review+
sspitzer
:
superreview+
|
Details | Diff | Splinter Review |
23.74 KB,
patch
|
peterv
:
review+
mscott
:
superreview+
jud
:
approval+
|
Details | Diff | Splinter Review |
This will probably be necessary for S/MIME support. We'll need to either modify the ::getValues method signature, or else add another method.
Assignee | ||
Updated•23 years ago
|
Status: NEW → ASSIGNED
QA Contact: olgac → yulian
Comment 1•23 years ago
|
||
cc'ing ssaux
Comment 2•23 years ago
|
||
Dan, when can we get this?
Assignee | ||
Comment 3•23 years ago
|
||
This isn't yet working, but it's got the structure in place, and shows what the interfaces will probably look like.
Assignee | ||
Comment 4•23 years ago
|
||
Peter, Kai: see what you think of this. I've filled in the implementation part of this, and it all even compiles. Give it a shot and see if it fits your needs...
Attachment #68886 -
Attachment is obsolete: true
Assignee | ||
Comment 5•23 years ago
|
||
Note to self: still need to file a bug about merging with or obsoleting nsIByteBuffer.h before I check this in.
Comment 6•23 years ago
|
||
Comment on attachment 69198 [details] [diff] [review] hopefully functional patch adding a getBinaryValues method, v2 >+nsLDAPBERValue::Get(PRUint32 *aCount, PRUint8 **aRetVal) >+{ >+ if (!mValue) { >+ return NS_ERROR_NOT_INITIALIZED; >+ } >+ >+ // get a buffer to hold a copy of the data >+ // >+ PRUint8 *array; >+ array = NS_STATIC_CAST(PRUint8 *, nsMemory::Alloc(mSize)); >+ if (!array) { >+ return NS_ERROR_OUT_OF_MEMORY; >+ } >+ >+ // copy and return >+ // >+ memcpy(array, mValue, mSize); >+ return NS_OK; >+} I think you want to set *aCount and *aRetVal here. >+// void set(in unsigned long aCount, >+// [array, size_is(aCount)] in octet aValue); >+NS_IMETHODIMP >+nsLDAPBERValue::Set(PRUint32 aCount, PRUint8 *aValue) >+{ >+ // get rid of any old value being held here >+ // >+ if (mValue) { >+ nsMemory::Free(mValue); >+ } >+ >+ // get a buffer to hold a copy of this data >+ // >+ mValue = NS_STATIC_CAST(PRUint8 *, nsMemory::Alloc(aCount)); >+ if (!mValue) { >+ return NS_ERROR_OUT_OF_MEMORY; >+ } >+ >+ // copy the data and return >+ // >+ memcpy(mValue, aValue, mSize); >+ return NS_OK; >+} I think you want to set mSize to aCount. >+// void setFromString(in AString aValue); >+// >+NS_IMETHODIMP >+nsLDAPBERValue::SetFromString(const nsAString & aValue) >+{ >+ // get rid of any old value being held here >+ // >+ if (mValue) { >+ nsMemory::Free(mValue); >+ } >+ >+ // get a UTF8 version >+ // >+ NS_ConvertUCS2toUTF8 utf8Value(aValue); >+ >+ // get a buffer to hold a copy of this data >+ // >+ // Note: at the time of this writing, .Length() appears to be the >+ // only way to get the size in bytes of a particular >+ // NS_ConvertUCS2toUTF8 string. It wouldn't be entirely suprising >+ // if the semantics of .Length were corrected, and .Size() were used >+ // for that function, at which point this code would need to be tweaked >+ // also. >+ // >+ mValue = NS_STATIC_CAST(PRUint8 *, nsMemory::Alloc(utf8Value.Length())); >+ if (!mValue) { >+ return NS_ERROR_OUT_OF_MEMORY; >+ } >+ >+ // copy the data and return >+ // >+ memcpy(mValue, utf8Value.get(), utf8Value.Length()); >+ return NS_OK; >+} Same here. >+ // clone the berval array into an nsISupportsArray >+ // >+ PRUint32 i(0); I find PRUint32 i = 0; clearer. Matter of style i guess. You'll need some mac project changes. Let me know if you expect me to do them.
Updated•23 years ago
|
Assignee | ||
Comment 7•23 years ago
|
||
OK, this version fixes the problems found by peterv. If you felt like doing the mac buildsystem patch, that'd be nifty; but if not, that's ok too. Lemme know. :-)
Attachment #69198 -
Attachment is obsolete: true
Assignee | ||
Comment 8•23 years ago
|
||
Bug 125596 has been filed about replacing ns{I}ByteBuffer.
Assignee | ||
Updated•23 years ago
|
Target Milestone: mozilla0.9.9 → mozilla1.0
Comment 9•22 years ago
|
||
Mail News team needs info: Stephane, is this a requirement for SMIME?
Whiteboard: needinfo
Comment 10•22 years ago
|
||
Michael, you asked Stephane a question, but I just realize that he was not on the CC list. I think we want this for the beta. I didn't have time to work on bug 119394 yet, but that's what I want to do in the next few days.
Comment 11•22 years ago
|
||
Please update this bug with an [adt1] - [adt3] impact rating (or take it off the list if it doesn't even rate adt3.) Thanks!
Assignee | ||
Comment 12•22 years ago
|
||
After some discussion with peterv a while back, I became convinced to switch away from nsISupportsArray and just use an XPCOM array. Given that most binary attributes are going to have usually one, sometimes a few, values, nsILDAPMessage::GetBinaryAttributes is the wrong place to try and optimize using an nsISupportsArray anyhow. Conceivably making nsILDAPBERValue return some sort of array reference might speed things up a bit, but it's unclear whether that would be particularly noticable. I'll be attaching a new patch shortly.
Assignee | ||
Comment 13•22 years ago
|
||
OK, here we go. peterv, kaie: whaddya think?
Attachment #69524 -
Attachment is obsolete: true
Assignee | ||
Comment 14•22 years ago
|
||
Had to adjust a few headers outside of the XPCOM SDK to cope with #include file changes, and also made a few tweaks to avoid unnecessarily breaking backwards compatibility.
Attachment #79007 -
Attachment is obsolete: true
Comment 15•22 years ago
|
||
Discussed at mail news bug meeting. Decided to minus this bug.
Comment 16•22 years ago
|
||
Minusing this bug kills a needed enterprise S/MIME fix. Can we reconsider?
Assignee | ||
Comment 17•22 years ago
|
||
Note to self: need to add assertions to check that get*Values is being called on messages of the ENTRY type and no others.
Comment 18•22 years ago
|
||
Michael, please have a look at Stephane's answer to your comment. We would like to ask you to reconsider this bug. I finally had time to try this patch. It works great! Thanks, Dan! The code in bug 119394 already works. This bug blocks 119394, and we want 119394 for RTM.
Comment 19•22 years ago
|
||
Comment on attachment 79222 [details] [diff] [review] getBinaryValues patch, v5 r=kaie
Attachment #79222 -
Flags: review+
Comment 20•22 years ago
|
||
PM chime in: this fnctionality is CRITICAL for S/MIME and RTM.
Comment 21•22 years ago
|
||
Raising priority as per Jeff's comment.
Comment 22•22 years ago
|
||
adding jhooker to bug
Comment 23•22 years ago
|
||
Please don't change bugs to nsbeta1+ or change the impact of bugs that you or your team don't own. In order for this to be considered, you'll need to get a super review and get this baked on the trunk very soon.
Whiteboard: [adt1 rtm] → [adt2 rtm]
Comment 24•22 years ago
|
||
Comment on attachment 79222 [details] [diff] [review] getBinaryValues patch, v5 >Index: directory/xpcom/base/public/nsILDAPMessage.idl >=================================================================== >RCS file: /cvsroot/mozilla/directory/xpcom/base/public/nsILDAPMessage.idl,v >retrieving revision 1.12 >diff -u -r1.12 nsILDAPMessage.idl >--- directory/xpcom/base/public/nsILDAPMessage.idl 20 Sep 2001 07:46:52 -0000 1.12 >+++ directory/xpcom/base/public/nsILDAPMessage.idl 15 Apr 2002 05:32:24 -0000 >@@ -178,4 +180,20 @@ > * it also returns the closest existing DN to the entry requested. > */ > readonly attribute AString matchedDn; >+ >+ /** >+ * Get an array of all the attribute values in this message (a wrapper >+ * around the LDAP C SDK's get_values_len()). >+ * >+ * @param attr The attribute whose values are to be returned >+ * @param count Number of values in the outbound array. >+ * @param values Array of nsILDAPBERValue objects >+ * >+ * @exception NS_ERROR_UNEXPECTED Bug or memory corruption >+ * @exception NS_ERROR_LDAP_DECODING_ERROR Attribute not found or other >+ * decoding error. >+ * @exception NS_ERROR_OUT_OF_MEMORY >+ */ >+ void getBinaryValues(in string attr, out unsigned long count, >+ [retval, array, size_is(count)] out nsILDAPBERValue values); Line up the second line to 'in string attr, ...' >+NS_IMETHODIMP >+nsLDAPMessage::GetBinaryValues(const char *aAttr, PRUint32 *aCount, >+ nsILDAPBERValue ***aValues) >+{ >+ struct berval **values; >+ >+ PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, >+ ("nsLDAPMessage::GetBinaryValues(): called with aAttr = '%s'", >+ aAttr)); >+ >+ values = ldap_get_values_len(mConnectionHandle, mMsgHandle, aAttr); >+ >+ // bail out if there was a problem >+ // >+ if (!values) { >+ PRInt32 lderrno = ldap_get_lderrno(mConnectionHandle, 0, 0); >+ >+ if ( lderrno == LDAP_DECODING_ERROR ) { >+ // this may not be an error; it could just be that the >+ // caller has asked for an attribute that doesn't exist. >+ // >+ PR_LOG(gLDAPLogModule, PR_LOG_WARNING, >+ ("nsLDAPMessage::GetBinaryValues(): ldap_get_values " >+ "returned LDAP_DECODING_ERROR")); >+ return NS_ERROR_LDAP_DECODING_ERROR; >+ >+ } else if ( lderrno == LDAP_PARAM_ERROR ) { >+ NS_ERROR("nsLDAPMessage::GetBinaryValues(): internal error: 1"); >+ return NS_ERROR_UNEXPECTED; >+ >+ } else { >+ NS_ERROR("nsLDAPMessage::GetBinaryValues(): internal error: 2"); >+ return NS_ERROR_UNEXPECTED; >+ } >+ } >+ >+ // count the values >+ // >+ PRUint32 numVals = ldap_count_values_len(values); >+ >+ // create the out array >+ // >+ *aValues = NS_STATIC_CAST(nsILDAPBERValue **, >+ nsMemory::Alloc(numVals * sizeof(nsILDAPBERValue))); Line up the second line with 'nsILDAPBERValue **,' >Index: extensions/pref/autoconfig/src/nsLDAPSyncQuery.h >=================================================================== >RCS file: /cvsroot/mozilla/extensions/pref/autoconfig/src/nsLDAPSyncQuery.h,v >retrieving revision 1.1 >diff -u -r1.1 nsLDAPSyncQuery.h >--- extensions/pref/autoconfig/src/nsLDAPSyncQuery.h 21 Dec 2001 22:22:01 -0000 1.1 >+++ extensions/pref/autoconfig/src/nsLDAPSyncQuery.h 15 Apr 2002 05:32:30 -0000 >@@ -39,6 +39,7 @@ > > #include "nsCOMPtr.h" > #include "nsILDAPConnection.h" >+#include "nsILDAPOperation.h" > #include "nsILDAPMessageListener.h" > #include "nsILDAPURL.h" > #include "nsString.h" >Index: xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.h >=================================================================== >RCS file: /cvsroot/mozilla/xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.h,v >retrieving revision 1.10 >diff -u -r1.10 nsLDAPAutoCompleteSession.h >--- xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.h 5 Oct 2001 02:59:31 -0000 1.10 >+++ xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.h 15 Apr 2002 05:32:30 -0000 >@@ -24,6 +24,7 @@ > #include "nsCOMPtr.h" > #include "nsIAutoCompleteSession.h" > #include "nsILDAPConnection.h" >+#include "nsILDAPOperation.h" > #include "nsILDAPMessageListener.h" > #include "nsILDAPAutoCompleteSession.h" > #include "nsILDAPAutoCompFormatter.h" Why do you need those two chunks? r=peterv
Comment 25•22 years ago
|
||
> Line up the second line to 'in string attr, ...' > Line up the second line with 'nsILDAPBERValue **,' done, attaching new patch, only alignments changed. > Why do you need those two chunks? It doesn't compile without them. Dan removed #include "nsILDAPOperation.idl" from nsILDAPMessage.idl, and replaced it with an interface forward declaration. I suspect he did so because of recursion problems. But because the size of the type is no longer known in source files, you have to include the header in source files.
Attachment #79222 -
Attachment is obsolete: true
Comment 26•22 years ago
|
||
Comment on attachment 86187 [details] [diff] [review] getBinaryValues patch, v6 carrying forward r=peterv
Attachment #86187 -
Flags: review+
Comment 27•22 years ago
|
||
The code patch did not yet contain the changes to the Mac build system. They are now contained in this separate patch. I don't have a Mac, but I think this patch should work.
Comment 28•22 years ago
|
||
Attachment #86188 -
Attachment is obsolete: true
Comment 29•22 years ago
|
||
Now with all the changes :-)
Attachment #86211 -
Attachment is obsolete: true
Comment 30•22 years ago
|
||
Comment on attachment 86211 [details] [diff] [review] Slightly better macbuild patch r=kaie
Attachment #86211 -
Flags: review+
Updated•22 years ago
|
Attachment #86211 -
Flags: review+
Comment 31•22 years ago
|
||
Comment on attachment 86212 [details] [diff] [review] Slightly better macbuild patch r=kaie
Attachment #86212 -
Flags: review+
Comment 32•22 years ago
|
||
Comment on attachment 86187 [details] [diff] [review] getBinaryValues patch, v6 sr=sspitzer some comments: 1) do you think we need a getAsUTF8()? dmose says: "no, not at this point." 2) can a LDAP BER value be 0 bytes long? I'm worried about the server (or our code) setting or getting a ber value with 0 bytes. what will alloc() and memcpy crash in that scenario? should we make the code check and bail in this scenario? 3) +// void setFromString(in AUTF8String aValue); +// +NS_IMETHODIMP +nsLDAPBERValue::SetFromUTF8(const nsACString & aValue) comment doesn't match actual method name.
Attachment #86187 -
Flags: superreview+
Comment 33•22 years ago
|
||
Comment on attachment 86212 [details] [diff] [review] Slightly better macbuild patch sr=sspitzer assuming that someone with a mac has built with these changes. "I don't have a Mac, but I think this patch should work." those are some scary-tinderbox-goes-red words.
Attachment #86212 -
Flags: superreview+
Comment 34•22 years ago
|
||
Was someone able to build on the Mac? This should get landed on the trunk and verified. If this doesn't get approved for the trunk, then I'd suggest building a test build and getting QA verification. I'm not sure if you'll need 119394 before doing this.
Whiteboard: [adt2 rtm] → [adt1 rtm]
Comment 35•22 years ago
|
||
I'll be testing this today.
Comment 36•22 years ago
|
||
Builds fine on Mac.
Comment 37•22 years ago
|
||
This is a rather enormous patch. What is being done to ensure adequate test coverage? Is it possible to limit any damage to the actual attempted use of this feature? (That is, don't have anything bad happen unless an actual binary attribute exists and is referenced.)
Assignee | ||
Updated•22 years ago
|
Priority: P2 → P1
Assignee | ||
Comment 38•22 years ago
|
||
selmer: this patch is entirely a new feature, and won't affect any existing functionality. The only caller of this code will be the code in bug 119394, and testing plans for that have been appended to that bug.
Assignee | ||
Comment 39•22 years ago
|
||
I tweaked the interface comments a bit, as well as the implementation in nsLDAPBerValue.cpp to address the zero-length comment. I talked to mcs, and zero-length BER values are legit, so this has changed to permit that. This means that C++ callers MUST check the size of the array before de-referencing it. kai, can you test this latest version with your patch? peterv, can you re-review?
Attachment #86187 -
Attachment is obsolete: true
Comment 40•22 years ago
|
||
dmose: I diffed the last two versions of your patch, you are no longer including the last two hunks to mozilla/extensions/pref/autoconfig/src/nsLDAPSyncQuery.h and mozilla/xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.h. (I guess you forgot them accidentially.) Note to reviewers: These missing hunks should not stop you from reviewing, they only contain added #include statements.
Comment 41•22 years ago
|
||
I tested the latest version of this patch with the patch in bug 119394. It still works for me.
Assignee | ||
Comment 42•22 years ago
|
||
Kai: good catch; thanks! I did inadvertantly forget to diff those two files. Here's a new, corrected patch.
Attachment #87334 -
Attachment is obsolete: true
Comment 43•22 years ago
|
||
The goal is to land 119394 by the end of the week. I assume this has to go with it. Will this be ready with the r=/sr=?
Comment 44•22 years ago
|
||
Comment on attachment 87404 [details] [diff] [review] getBinaryValues patch, v8 r=peterv
Attachment #87404 -
Flags: review+
Assignee | ||
Comment 45•22 years ago
|
||
putterman: as soon as this patch gets final sr (which I've already mailed mscott for), the patches for both bugs can land on the trunk.
Comment 46•22 years ago
|
||
Comment on attachment 87404 [details] [diff] [review] getBinaryValues patch, v8 sr=mscott
Attachment #87404 -
Flags: superreview+
Assignee | ||
Comment 47•22 years ago
|
||
Fixed on the trunk. Still needs to land on the branch.
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Keywords: adt1.0.1,
mozilla1.0.1
Resolution: --- → FIXED
Comment 48•22 years ago
|
||
This checking have added two "might be used uninitialized" warnings: +directory/xpcom/base/src/nsLDAPBERValue.cpp:59 + `PRUint8 * array' might be used uninitialized in this function + +directory/xpcom/base/src/nsLDAPMessage.cpp:600 + `nsresult rv' might be used uninitialized in this function
This bug, a low-level API, blocked bug 119394, which is now also fixed. (Meaning that this code works). I've also checked LXR on the trunk, and all of the files in http://bugzilla.mozilla.org/attachment.cgi?id=87404&action=view have landed. Marking VERIFIED for the trunk's state.
Status: RESOLVED → VERIFIED
Comment 50•22 years ago
|
||
I have indeed verified in bug 119394 that binary certs are being downloaded successfully into the 20020614 Trunk builds and can be used properly.
Comment 51•22 years ago
|
||
adding adt1.0.1+. Please get drivers approval before checking into the branch.
Updated•22 years ago
|
Attachment #87404 -
Flags: approval+
Comment 52•22 years ago
|
||
please checkin to the 1.0.1 branch. once there, remove the "mozilla1.0.1+" keyword and add the "fixed1.0.1" keyword.
Keywords: mozilla1.0.1 → mozilla1.0.1+
Assignee | ||
Comment 53•22 years ago
|
||
Fixed on the branch. Bug 152700 has been opened about the warnings; I've got a patch for them there.
Keywords: mozilla1.0.1+ → fixed1.0.1
Comment 54•22 years ago
|
||
Based on Charles Rosendahl's verification on branch build: http://bugzilla.mozilla.org/show_bug.cgi?id=119394, Marked this bug fix verified on branch.
Keywords: fixed1.0.1 → verified1.0.1
You need to log in
before you can comment on or make changes to this bug.
Description
•