summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-11-15 14:52:03 +0100
committerDavid Sterba <dsterba@suse.com>2016-11-23 10:50:08 +0100
commit4c066138426be59c9f8c6956f4d02c941042c55c (patch)
tree0b08620c88c5cb7b89c74655bff7aaf1e3e3ccd0
parentd13168cebfa0aeb7675157de64466570fbfd8155 (diff)
btrfs-progs: send-stream: use proper types for tlv header values
Switch types to unsigned and adjust the checks. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--send-stream.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/send-stream.c b/send-stream.c
index 376c8cc9..3720e7df 100644
--- a/send-stream.c
+++ b/send-stream.c
@@ -74,11 +74,8 @@ static int read_cmd(struct btrfs_send_stream *sctx)
int ret;
int cmd;
u32 cmd_len;
- int tlv_type;
- int tlv_len;
char *data;
u32 pos;
- struct btrfs_tlv_header *tlv_hdr;
u32 crc;
u32 crc2;
@@ -129,13 +126,17 @@ static int read_cmd(struct btrfs_send_stream *sctx)
pos = 0;
while (pos < cmd_len) {
+ struct btrfs_tlv_header *tlv_hdr;
+ u16 tlv_type;
+ u16 tlv_len;
+
tlv_hdr = (struct btrfs_tlv_header *)data;
tlv_type = le16_to_cpu(tlv_hdr->tlv_type);
tlv_len = le16_to_cpu(tlv_hdr->tlv_len);
- if (tlv_type <= 0 || tlv_type > BTRFS_SEND_A_MAX ||
- tlv_len < 0 || tlv_len > BTRFS_SEND_BUF_SIZE) {
- error("invalid tlv in cmd tlv_type = %d, tlv_len = %d",
+ if (tlv_type == 0 || tlv_type > BTRFS_SEND_A_MAX
+ || tlv_len > BTRFS_SEND_BUF_SIZE) {
+ error("invalid tlv in cmd tlv_type = %hu, tlv_len = %hu",
tlv_type, tlv_len);
ret = -EINVAL;
goto out;