iotaledger / entangled

enTangle'd is an amalgamation of all things Tangle
Apache License 2.0
113 stars 66 forks source link

Tryte conversion in MAM #1389

Open semenov-vladyslav opened 5 years ago

semenov-vladyslav commented 5 years ago

Problem

In some places of MAM trits_from_str is used to convert from trytes string to trits (see eg. https://github.com/iotaledger/entangled/blob/develop/mam/psk/psk.c#L23). This function returns bool which is not checked, this might lead to UB (in case string contains bad characters or too short).

In other places mam_api_channel_get is used which is unsafe in case string contains bad characters.

Solution