Index: /trunk/src/VBox/Devices/Network/slirp/tftp.c
===================================================================
--- /trunk/src/VBox/Devices/Network/slirp/tftp.c	(revision 42179)
+++ /trunk/src/VBox/Devices/Network/slirp/tftp.c	(revision 42180)
@@ -58,5 +58,5 @@
 {
     int fRequested;
-    int u16Value;
+    uint64_t u64Value;
 } TFPTPSESSIONOPTDESC, *PTFPTPSESSIONOPTDESC;
 
@@ -73,5 +73,4 @@
     TFPTPSESSIONOPTDESC OptionBlkSize;
     TFPTPSESSIONOPTDESC OptionTSize;
-    TFPTPSESSIONOPTDESC OptionSize;
     TFPTPSESSIONOPTDESC OptionTimeout;
 } TFTPSESSION, *PTFTPSESSION, **PPTFTPSESSION;
@@ -244,5 +243,5 @@
 {
     int rc  = VINF_SUCCESS;
-    rc = RTStrToInt16Full(pcszRawOption, 0, (int16_t *)&pTftpSessionOption->u16Value);
+    rc = RTStrToInt64Full(pcszRawOption, 0, (int64_t *)&pTftpSessionOption->u64Value);
     AssertRCReturn(rc, rc);
     pTftpSessionOption->fRequested = 1;
@@ -293,12 +292,13 @@
             if (!RTStrICmp("blksize", g_TftpDesc[idxOptionArg].pszName))
                 rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionBlkSize);
-            else if (!RTStrICmp("size", g_TftpDesc[idxOptionArg].pszName))
-                rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionSize);
-            else if (!RTStrICmp("tsize", g_TftpDesc[idxOptionArg].pszName))
+            if (!RTStrICmp("tsize", g_TftpDesc[idxOptionArg].pszName))
                 rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionTSize);
-            else if (!RTStrICmp("timeoute", g_TftpDesc[idxOptionArg].pszName))
-                rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionSize);
+            if (!RTStrICmp("timeoute", g_TftpDesc[idxOptionArg].pszName))
+                rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionTimeout);
+/*
+            @todo: process unrecognized options ??
             else
                 rc = VERR_INVALID_PARAMETER;
+*/
             if (RT_FAILURE(rc))
             {
@@ -397,4 +397,5 @@
     size_t cbSessionFileName;
     int rc = VINF_SUCCESS;
+    LogFlowFuncEnter();
     cbSessionFileName = RTStrPrintf(aszSessionFileName, TFTP_FILENAME_MAX, "%s/%s",
                     tftp_prefix, pTftpSession->pszFilename);
@@ -404,4 +405,5 @@
         return VERR_INTERNAL_ERROR;
     }
+    LogFunc(("aszSessionFileName: %s\n", aszSessionFileName));
 
     if (!RTFileExists(aszSessionFileName))
@@ -439,9 +441,11 @@
 
     if (pTftpSession->OptionTSize.fRequested)
-        pTftpSession->OptionTSize.u16Value = (uint16_t)cbSessionFile;
-    if (   !pTftpSession->OptionBlkSize.u16Value
+    {
+       pTftpSession->OptionTSize.u64Value = cbSessionFile;
+    }
+    if (   !pTftpSession->OptionBlkSize.u64Value
         && !pTftpSession->OptionBlkSize.fRequested)
     {
-        pTftpSession->OptionBlkSize.u16Value = 1428;
+        pTftpSession->OptionBlkSize.u64Value = 1428;
     }
     LogFlowFuncLeaveRC(rc);
@@ -484,4 +488,5 @@
     AssertPtrReturn(pu8Data, VERR_INVALID_PARAMETER);
     AssertPtrReturn(pcbReadData, VERR_INVALID_PARAMETER);
+    AssertReturn(pcTftpSession->OptionBlkSize.u64Value < UINT16_MAX, VERR_INVALID_PARAMETER);
     LogFlowFunc(("pcTftpSession:%p, pu8Data:%p, pcbReadData:%p\n",
                     pcTftpSession,
@@ -489,5 +494,5 @@
                     pcbReadData));
 
-    u16BlkSize = pcTftpSession->OptionBlkSize.u16Value;
+    u16BlkSize = (uint16_t)pcTftpSession->OptionBlkSize.u64Value;
     rc = pftpSessionOpenFile(pData, pcTftpSession, &hSessionFile);
     if (RT_FAILURE(rc))
@@ -524,5 +529,5 @@
 }
 
-DECLINLINE(int) tftpAddOptionToOACK(PNATState pData, struct mbuf *pMBuf, const char *pszOptName, uint16_t u16OptValue)
+DECLINLINE(int) tftpAddOptionToOACK(PNATState pData, struct mbuf *pMBuf, const char *pszOptName, uint64_t u64OptValue)
 {
     char aszOptionBuffer[256];
@@ -530,5 +535,5 @@
     int rc = VINF_SUCCESS;
     int cbMBufCurrent = pMBuf->m_len;
-    LogFlowFunc(("pMBuf:%p, pszOptName:%s, u16OptValue:%u\n", pMBuf, pszOptName, u16OptValue));
+    LogFlowFunc(("pMBuf:%p, pszOptName:%s, u16OptValue:%ld\n", pMBuf, pszOptName, u64OptValue));
     AssertPtrReturn(pMBuf, VERR_INVALID_PARAMETER);
     AssertPtrReturn(pszOptName, VERR_INVALID_PARAMETER);
@@ -536,5 +541,5 @@
     RT_ZERO(aszOptionBuffer);
     iOptLength += RTStrPrintf(aszOptionBuffer, 256 , "%s", pszOptName) + 1;
-    iOptLength += RTStrPrintf(aszOptionBuffer + iOptLength, 256 - iOptLength , "%u", u16OptValue) + 1;
+    iOptLength += RTStrPrintf(aszOptionBuffer + iOptLength, 256 - iOptLength , "%u", u64OptValue) + 1;
     if (iOptLength > M_TRAILINGSPACE(pMBuf))
         rc = VERR_BUFFER_OVERFLOW; /* buffer too small */
@@ -578,9 +583,12 @@
 
     if (pTftpSession->OptionBlkSize.fRequested)
-        rc = tftpAddOptionToOACK(pData, m, "blksize", pTftpSession->OptionBlkSize.u16Value);
-    else if (pTftpSession->OptionSize.fRequested)
-        rc = tftpAddOptionToOACK(pData, m, "size", pTftpSession->OptionSize.u16Value);
-    else if (pTftpSession->OptionTSize.fRequested)
-        rc = tftpAddOptionToOACK(pData, m, "tsize", pTftpSession->OptionTSize.u16Value);
+    {
+        if (pTftpSession->OptionBlkSize.u64Value > UINT16_MAX)
+            return -1;
+        else
+            rc = tftpAddOptionToOACK(pData, m, "blksize", pTftpSession->OptionBlkSize.u64Value);
+    }
+    if (pTftpSession->OptionTSize.fRequested)
+        rc = tftpAddOptionToOACK(pData, m, "tsize", pTftpSession->OptionTSize.u64Value);
 
     rc = tftpSend(pData, pTftpSession, m, pcTftpIpHeaderRecv);
@@ -597,7 +605,11 @@
     PTFTPIPHDR pTftpIpHeader = NULL;
 
+    LogFlowFunc(("ENTER: errorcode: %RX16, msg: %s\n", errorcode, msg));
     m = slirpTftpMbufAlloc(pData);
     if (!m)
+    {
+        LogFlowFunc(("LEAVE: Can't allocate mbuf\n"));
         return -1;
+    }
 
     m->m_data += if_maxlinkhdr;
@@ -616,4 +628,5 @@
     tftpSessionTerminate(pTftpSession);
 
+    LogFlowFuncLeave();
     return 0;
 }
@@ -626,5 +639,5 @@
     struct mbuf *m;
     PTFTPIPHDR pTftpIpHeader;
-    int cbRead;
+    int cbRead = 0;
     int rc = VINF_SUCCESS;
 
