Skip to content

Commit

Permalink
tls: rx: replace 'back' with 'offset'
Browse files Browse the repository at this point in the history
The padding length TLS 1.3 logic is searching for content_type from
the end of text. IMHO the code is easier to parse if we calculate
offset and decrement it rather than try to maintain positive offset
from the end of the record called "back".

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jakub Kicinski authored and David S. Miller committed Apr 8, 2022
1 parent a8340cc commit 5deee41
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions net/tls/tls_sw.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,21 @@ static int padding_length(struct tls_prot_info *prot, struct sk_buff *skb)

/* Determine zero-padding length */
if (prot->version == TLS_1_3_VERSION) {
int back = TLS_TAG_SIZE + 1;
int offset = rxm->full_len - TLS_TAG_SIZE - 1;
char content_type = 0;
int err;

while (content_type == 0) {
if (back > rxm->full_len - prot->prepend_size)
if (offset < prot->prepend_size)
return -EBADMSG;
err = skb_copy_bits(skb,
rxm->offset + rxm->full_len - back,
err = skb_copy_bits(skb, rxm->offset + offset,
&content_type, 1);
if (err)
return err;
if (content_type)
break;
sub++;
back++;
offset--;
}
tlm->control = content_type;
}
Expand Down

0 comments on commit 5deee41

Please sign in to comment.