/*
- * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
&& !put_value(&buf[sub->packet_len], packlen,
sub->lenbytes))
return 0;
- } else if (pkt->endfirst && sub->parent != NULL) {
+ } else if (pkt->endfirst && sub->parent != NULL
+ && (packlen != 0
+ || (sub->flags
+ & WPACKET_FLAGS_ABANDON_ON_ZERO_LENGTH) == 0)) {
size_t tmplen = packlen;
size_t numlenbytes = 1;