diff options
author | Ren Kararou <[email protected]> | 2025-01-11 23:38:03 -0600 |
---|---|---|
committer | Ren Kararou <[email protected]> | 2025-01-11 23:38:03 -0600 |
commit | 5d087643d3b4aacc907e119d992fbc4038130941 (patch) | |
tree | b3a35a2d2d336654919c381329ad302ab7cb33b7 /src/packet.c | |
parent | b1b3e7eca4c8153d7c6a2422923ad4ec2b78a223 (diff) | |
download | nbtpd-5d087643d3b4aacc907e119d992fbc4038130941.tar.gz nbtpd-5d087643d3b4aacc907e119d992fbc4038130941.tar.bz2 nbtpd-5d087643d3b4aacc907e119d992fbc4038130941.zip |
working WRQ flow
Diffstat (limited to 'src/packet.c')
-rw-r--r-- | src/packet.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/packet.c b/src/packet.c index 0663b64..d439ec9 100644 --- a/src/packet.c +++ b/src/packet.c @@ -56,7 +56,7 @@ nbd_tftp_packet_data nbd_tftp_de_data(char *data, size_t len) { ret.opcode = ((uint16_t)data[0] << 8) + data[1]; ret.block_num = ((uint16_t)data[2] << 8) + data[3]; ret.datalen = len - 4; - if (ret.datalen <= 0) { + if (ret.datalen > 0) { if ((ret.data = malloc(ret.datalen)) != NULL) { memcpy(ret.data, (data + 4), ret.datalen); } @@ -104,7 +104,7 @@ char *nbd_tftp_ser_ack(nbd_tftp_packet_ack ack) { char *nbd_tftp_ser_ack_from_block_num(uint16_t block_num) { char *buf = malloc(sizeof(uint16_t) + sizeof(block_num)); if (buf != NULL) { - uint16_t netopcode = htons(5); + uint16_t netopcode = htons(4); uint16_t netbnum = htons(block_num); memcpy(buf, &netopcode, sizeof(netopcode)); memcpy((buf + sizeof(netopcode)), &netbnum, sizeof(netbnum)); |