[SERVER-8257] mod on empty string field causes read of byte before field name during validation Created: 21/Jan/13  Updated: 07/Dec/15  Resolved: 07/Dec/15

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Aaron Staple Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

                uassert( 10149,
                         "Invalid mod field name, may not end in a period",
                         fieldName[ strlen( fieldName ) - 1 ] != '.' );

If strlen( fieldName ) == 0, this will read a character before the beginning of fieldName. Because fieldName will point to a field name within a bson element, this will not cause undefined or incorrect behavior currently. But we might want to clean it up a bit.

Test to trigger

c = db.c;
c.drop();
 
c.save( {} );
c.update( {}, { $set:{ '':4 } } );
printjson( c.findOne() );



 Comments   
Comment by David Storch [ 07/Dec/15 ]

I think this was cleaned up during the 2.5 development cycle as part of the update refactor project. The new implementation errors nicely due to the empty path component passed to the $set modifier:

> c.update( {}, { $set:{ '':4 } } );
WriteResult({
	"nMatched" : 0,
	"nUpserted" : 0,
	"nModified" : 0,
	"writeError" : {
		"code" : 56,
		"errmsg" : "An empty update path is not valid."
	}
})

Closing as Gone Away.

Generated at Thu Feb 08 03:16:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.