[1.7.x] Fixed #22426 -- Added support old-style d.c.messages format.
Forward ported code from 1.5 that adds backwards compatibility with legacy message length.
See commit 9e718307 for details.
Thanks to Ofir Ovadia for the initial patch.
Backport of f286721f from master.