@@ -115,6 +115,7 @@ u8 *gossip_store_next(const tal_t *ctx,
115115 size_t * off , size_t * end )
116116{
117117 u8 * msg = NULL ;
118+ size_t initial_off = * off ;
118119
119120 while (!msg ) {
120121 struct gossip_hdr hdr ;
@@ -146,6 +147,14 @@ u8 *gossip_store_next(const tal_t *ctx,
146147 continue ;
147148 }
148149
150+ /* Messages can be up to 64k, but we also have internal ones:
151+ * 128k is plenty. */
152+ if (msglen > 128 * 1024 )
153+ status_failed (STATUS_FAIL_INTERNAL_ERROR ,
154+ "gossip_store: oversize msg len %u at"
155+ " offset %zu (was at %zu)" ,
156+ msglen , * off , initial_off );
157+
149158 checksum = be32_to_cpu (hdr .crc );
150159 msg = tal_arr (ctx , u8 , msglen );
151160 r = pread (* gossip_store_fd , msg , msglen , * off + r );
@@ -155,8 +164,8 @@ u8 *gossip_store_next(const tal_t *ctx,
155164 if (checksum != crc32c (be32_to_cpu (hdr .timestamp ), msg , msglen ))
156165 status_failed (STATUS_FAIL_INTERNAL_ERROR ,
157166 "gossip_store: bad checksum at offset %zu"
158- ": %s" ,
159- * off , tal_hex (tmpctx , msg ));
167+ "(was at %zu) : %s" ,
168+ * off , initial_off , tal_hex (tmpctx , msg ));
160169
161170 /* Definitely processing it now */
162171 * off += sizeof (hdr ) + msglen ;
0 commit comments