Handle the transfer size option when faking up /etc/random.seed.
authornaddy <naddy@openbsd.org>
Fri, 26 Jan 2018 16:40:14 +0000 (16:40 +0000)
committernaddy <naddy@openbsd.org>
Fri, 26 Jan 2018 16:40:14 +0000 (16:40 +0000)
Without this, clients that queried the size would receive 0 as response.
ok jca@

usr.sbin/tftpd/tftpd.c

index 8536cf5..b3c708b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: tftpd.c,v 1.40 2017/11/07 14:15:38 jca Exp $  */
+/*     $OpenBSD: tftpd.c,v 1.41 2018/01/26 16:40:14 naddy Exp $        */
 
 /*
  * Copyright (c) 2012 David Gwynne <dlg@uq.edu.au>
@@ -973,6 +973,8 @@ validate_access(struct tftp_client *client, const char *requested)
 
                buf = client->buf + sizeof(client->buf) - 512;
                arc4random_buf(buf, 512);
+               if (options != NULL && options[OPT_TSIZE].o_request)
+                       options[OPT_TSIZE].o_reply = 512;
                client->file = fmemopen(buf, 512, "r");
                if (client->file == NULL)
                        return (errno + 100);