Duplicate Key in Associative List (Alist) |
Weakness ID: 462 (Weakness Base) | Status: Incomplete |
Description Summary
Duplicate keys in associative lists can lead to non-unique keys being mistaken for an error.
Extended Description
A duplicate key entry -- if the alist is designed properly -- could be used as a constant time replace function. However, duplicate key entries could be inserted by mistake. Because of this ambiguity, duplicate key entries in an association list are not recommended and should not be allowed.
Example 1
The following code adds data to a list and then attempts to sort the data.
(Bad Code)
alist = []
while (foo()): #now assume there is a string data with a key basename
queue.append(basename,data)
queue.sort()
Since basename is not necessarily unique, this may not sort how one would like it to be.
Phase: Architecture and Design Use a hash table instead of an alist. |
Phase: Architecture and Design Use an alist which checks the uniqueness of hash keys with each entry before inserting the entry. |
Nature | Type | ID | Name | View(s) this relationship pertains to![]() |
---|---|---|---|---|
ChildOf | ![]() | 461 | Data Structure Issues | Development Concepts (primary)699 |
ChildOf | ![]() | 694 | Use of Multiple Resources with Duplicate Identifier | Research Concepts (primary)1000 |
ChildOf | ![]() | 744 | CERT C Secure Coding Section 10 - Environment (ENV) | Weaknesses Addressed by the CERT C Secure Coding Standard (primary)734 |
Mapped Taxonomy Name | Node ID | Fit | Mapped Node Name |
---|---|---|---|
CLASP | Duplicate key in associative list (alist) | ||
CERT C Secure Coding | ENV02-C | Beware of multiple environment variables with the same effective name |
Submissions | ||||
---|---|---|---|---|
Submission Date | Submitter | Organization | Source | |
CLASP | Externally Mined | |||
Modifications | ||||
Modification Date | Modifier | Organization | Source | |
2008-07-01 | Eric Dalci | Cigital | External | |
updated Time of Introduction | ||||
2008-09-08 | CWE Content Team | MITRE | Internal | |
updated Applicable Platforms, Relationships, Other Notes, Taxonomy Mappings | ||||
2008-11-24 | CWE Content Team | MITRE | Internal | |
updated Relationships, Taxonomy Mappings | ||||
2009-10-29 | CWE Content Team | MITRE | Internal | |
updated Demonstrative Examples, Description, Other Notes |