msgpack deserializer being too strict?

157 views
Skip to first unread message

Sebastián Waisbrot

unread,
May 22, 2015, 8:10:34 PM5/22/15
to redi...@googlegroups.com
Hello all,

I suspect this to be a bug, but I'm not sure, so according to the guidelines I should post it in the mailing list first.

I'm using a msgpack serializer that produces the following string:

\x9c\xa6author\xa7Freepik\xa8en_names\xd9#vacaciones/cumplea\xc3\xb1os/festividades\xa9imageName\xa915864.png\xa9authorUrl\xb6http://www.freepik.com\xa2id\xa220\xa8sp_names\xbavacation/birthday/holidays

Redis is failing to unpack it, providing the following error:

(error) ERR Error running script (call to f_d84093efbb10df1c5995c6b0e7340520973b306d): @user_script:34: user_script:34: Bad data format in input.

Trying a different serializer for the same input I got the following string:

\x9C\xA6author\xA7Freepik\xA8en_names\xDA\x00#vacaciones/cumplea\xC3\xB1os/festividades\xA9imageName\xA915864.png\xA9authorUrl\xB6http://www.freepik.com\xA2id\xA220\xA8sp_names\xBAvacation/birthday/holidays

The only difference is in a header using "\xDA\x00" instead of "\xd9". The second one actually works as expected.

Taking a look at msgpack spec[1] the difference between those two headers is the maximum length of the string, and both str 8 and str 16 should be enough.

Trying to decode the serialized version with Ruby's MessagePack both version work fine[2].

If anyone wants to try it out, the script to reproduce is in https://gist.githubusercontent.com/seppo0010/a600a33856609c1bd6b8/raw/48d299499390200fe8c3fd53fe1831209af0b12b/gistfile1.txt

Thanks.

[1] https://github.com/msgpack/msgpack/blob/master/spec.md

[2] https://gist.github.com/seppo0010/cfd0da4a938a7fd1a401

Jan-Erik Rediger

unread,
May 22, 2015, 8:30:23 PM5/22/15
to redi...@googlegroups.com
Redis uses antirez' lua-cmsgpack library and indeed it looks like it
doesn't handle the 0xD9 case, but does handle the 0xDA case:
https://github.com/antirez/lua-cmsgpack/blob/master/lua_cmsgpack.c#L690

We should get this patched in lua-cmsgpack and then backport it into
Redis as well. :)

-- Jan-Erik
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
> To post to this group, send email to redi...@googlegroups.com.
> Visit this group at http://groups.google.com/group/redis-db.
> For more options, visit https://groups.google.com/d/optout.

Sebastián Waisbrot

unread,
May 22, 2015, 9:32:50 PM5/22/15
to redi...@googlegroups.com, jan...@fnordig.de
Thanks for confirming the problem and pointing me out where it was. I sent a PR to fix this.

https://github.com/antirez/lua-cmsgpack/pull/44
Reply all
Reply to author
Forward
0 new messages