[ 
https://issues.apache.org/jira/browse/FELIX-4304?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Herko ter Horst updated FELIX-4304:
-----------------------------------

    Description: 
In org.apache.felix.dm.impl.ComponentImpl.getServiceProperties() a copy of the 
internal field m_serviceProperties is created by casting to Hashtable and 
calling clone(). However, as clients are allowed to call 
setServiceProperties(Dictionary properties) which assigns the parameter value 
to the field, it is very possible for m_serviceProperties to contain some other 
Dictionary implementation.

The attached patch solves this problem in getServiceProperties() by making a 
copy by enumerating over all keys and putting them in a newly created Hashtable.

Alternatively (or in addition), setProperties() could be changed to ensure the 
parameter value isn't directly assigned to the field.

  was:
In org.apache.felix.dm.impl.ComponentImpl.getServiceProperties() a copy of the 
internal field m_serviceProperties is created by casting to Hashtable and 
calling clone(). However, as clients are allowed to call 
setServiceProperties(Dictionary properties) which assigns the parameter value 
to the field, it is very possible for m_serviceProperties to contain some other 
Dictionary implementation.

The attached patch doesn't solves this problem in getServiceProperties() by 
making a copy by enumerating over all keys and putting them in a newly created 
Hashtable.

Alternatively (or in addition), setProperties() could be changed to ensure the 
parameter value isn't directly assigned to the field.


> DependencyManager ComponentImpl should not assume all service properties are 
> stored in a Hashtable
> --------------------------------------------------------------------------------------------------
>
>                 Key: FELIX-4304
>                 URL: https://issues.apache.org/jira/browse/FELIX-4304
>             Project: Felix
>          Issue Type: Bug
>          Components: Dependency Manager
>    Affects Versions: dependencymanager-3.1.0
>            Reporter: Herko ter Horst
>            Assignee: Xander Uiterlinden
>         Attachments: ComponentImpl.java.patch
>
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> In org.apache.felix.dm.impl.ComponentImpl.getServiceProperties() a copy of 
> the internal field m_serviceProperties is created by casting to Hashtable and 
> calling clone(). However, as clients are allowed to call 
> setServiceProperties(Dictionary properties) which assigns the parameter value 
> to the field, it is very possible for m_serviceProperties to contain some 
> other Dictionary implementation.
> The attached patch solves this problem in getServiceProperties() by making a 
> copy by enumerating over all keys and putting them in a newly created 
> Hashtable.
> Alternatively (or in addition), setProperties() could be changed to ensure 
> the parameter value isn't directly assigned to the field.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to