VirtualBox

Ignore:
Timestamp:
Mar 12, 2019 12:40:12 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129295
Message:

EFI: First step in UDK2018 merge. Does not build yet.

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.uni

    r58464 r77662  
    1 // /** @file
     1// /** @file
    22// Client-side Mtftp6 service.
    33//
  • trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Mtftp6Dxe/Mtftp6DxeExtra.uni

    r58464 r77662  
    1 // /** @file
     1// /** @file
    22// Mtftp6Dxe Localized Strings and Content
    33//
  • trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/Mtftp6Dxe/Mtftp6Support.c

    r58459 r77662  
    22  Mtftp6 support functions implementation.
    33
    4   Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
     4  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
    55
    66  This program and the accompanying materials
     
    224224
    225225      if (Range->Round > 0) {
    226         *TotalBlock += Range->Bound +  MultU64x32 ((UINT64) (Range->Round -1), (UINT32)(Range->Bound + 1)) + 1;
     226        *TotalBlock += Range->Bound +  MultU64x32 (Range->Round - 1, (UINT32)(Range->Bound + 1)) + 1;
    227227      }
    228228
     
    320320
    321321    if (!EFI_ERROR (Status)) {
     322      if (Ip6Mode.AddressList != NULL) {
     323        FreePool (Ip6Mode.AddressList);
     324      }
     325
     326      if (Ip6Mode.GroupTable != NULL) {
     327        FreePool (Ip6Mode.GroupTable);
     328      }
     329
     330      if (Ip6Mode.RouteTable != NULL) {
     331        FreePool (Ip6Mode.RouteTable);
     332      }
     333
     334      if (Ip6Mode.NeighborCache != NULL) {
     335        FreePool (Ip6Mode.NeighborCache);
     336      }
     337
     338      if (Ip6Mode.PrefixTable != NULL) {
     339        FreePool (Ip6Mode.PrefixTable);
     340      }
     341
     342      if (Ip6Mode.IcmpTypeList != NULL) {
     343        FreePool (Ip6Mode.IcmpTypeList);
     344      }
    322345
    323346      if  (Ip6Mode.IsConfigured) {
     
    453476  EFI_MTFTP6_OPTION         *Options;
    454477  EFI_MTFTP6_TOKEN          *Token;
     478  RETURN_STATUS             Status;
    455479  NET_BUF                   *Nbuf;
    456480  UINT8                     *Mode;
    457481  UINT8                     *Cur;
    458   UINT32                    Len1;
    459   UINT32                    Len2;
    460   UINT32                    Len;
    461482  UINTN                     Index;
     483  UINT32                    BufferLength;
     484  UINTN                     FileNameLength;
     485  UINTN                     ModeLength;
     486  UINTN                     OptionStrLength;
     487  UINTN                     ValueStrLength;
    462488
    463489  Token   = Instance->Token;
     
    488514  // Compute the size of new Mtftp6 packet.
    489515  //
    490   Len1 = (UINT32) AsciiStrLen ((CHAR8 *) Token->Filename);
    491   Len2 = (UINT32) AsciiStrLen ((CHAR8 *) Mode);
    492   Len  = Len1 + Len2 + 4;
     516  FileNameLength = AsciiStrLen ((CHAR8 *) Token->Filename);
     517  ModeLength     = AsciiStrLen ((CHAR8 *) Mode);
     518  BufferLength   = (UINT32) FileNameLength + (UINT32) ModeLength + 4;
    493519
    494520  for (Index = 0; Index < Token->OptionCount; Index++) {
    495     Len1  = (UINT32) AsciiStrLen ((CHAR8 *) Options[Index].OptionStr);
    496     Len2  = (UINT32) AsciiStrLen ((CHAR8 *) Options[Index].ValueStr);
    497     Len  += Len1 + Len2 + 2;
     521    OptionStrLength = AsciiStrLen ((CHAR8 *) Options[Index].OptionStr);
     522    ValueStrLength  = AsciiStrLen ((CHAR8 *) Options[Index].ValueStr);
     523    BufferLength   += (UINT32) OptionStrLength + (UINT32) ValueStrLength + 2;
    498524  }
    499525
     
    501527  // Allocate a packet then copy the data.
    502528  //
    503   if ((Nbuf = NetbufAlloc (Len)) == NULL) {
     529  if ((Nbuf = NetbufAlloc (BufferLength)) == NULL) {
    504530    return EFI_OUT_OF_RESOURCES;
    505531  }
     
    508534  // Copy the opcode, filename and mode into packet.
    509535  //
    510   Packet         = (EFI_MTFTP6_PACKET *) NetbufAllocSpace (Nbuf, Len, FALSE);
     536  Packet         = (EFI_MTFTP6_PACKET *) NetbufAllocSpace (Nbuf, BufferLength, FALSE);
    511537  ASSERT (Packet != NULL);
    512538
    513539  Packet->OpCode = HTONS (Operation);
     540  BufferLength  -= sizeof (Packet->OpCode);
     541
    514542  Cur            = Packet->Rrq.Filename;
    515   Cur            = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Token->Filename);
    516   Cur           += AsciiStrLen ((CHAR8 *) Token->Filename) + 1;
    517   Cur            = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Mode);
    518   Cur           += AsciiStrLen ((CHAR8 *) Mode) + 1;
     543  Status         = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Token->Filename);
     544  ASSERT_EFI_ERROR (Status);
     545  BufferLength  -= (UINT32) (FileNameLength + 1);
     546  Cur           += FileNameLength + 1;
     547  Status         = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Mode);
     548  ASSERT_EFI_ERROR (Status);
     549  BufferLength  -= (UINT32) (ModeLength + 1);
     550  Cur           += ModeLength + 1;
    519551
    520552  //
     
    522554  //
    523555  for (Index = 0; Index < Token->OptionCount; ++Index) {
    524     Cur  = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Options[Index].OptionStr);
    525     Cur += AsciiStrLen ((CHAR8 *) Options[Index].OptionStr) + 1;
    526     Cur  = (UINT8 *) AsciiStrCpy ((CHAR8 *) Cur, (CHAR8 *) Options[Index].ValueStr);
    527     Cur += AsciiStrLen ((CHAR8 *) (CHAR8 *) Options[Index].ValueStr) + 1;
     556    OptionStrLength = AsciiStrLen ((CHAR8 *) Options[Index].OptionStr);
     557    ValueStrLength  = AsciiStrLen ((CHAR8 *) Options[Index].ValueStr);
     558
     559    Status          = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Options[Index].OptionStr);
     560    ASSERT_EFI_ERROR (Status);
     561    BufferLength   -= (UINT32) (OptionStrLength + 1);
     562    Cur            += OptionStrLength + 1;
     563
     564    Status          = AsciiStrCpyS ((CHAR8 *) Cur, BufferLength, (CHAR8 *) Options[Index].ValueStr);
     565    ASSERT_EFI_ERROR (Status);
     566    BufferLength   -= (UINT32) (ValueStrLength + 1);
     567    Cur            += ValueStrLength + 1;
     568
    528569  }
    529570
     
    585626  TftpError->Error.ErrorCode = HTONS (ErrCode);
    586627
    587   AsciiStrCpy ((CHAR8 *) TftpError->Error.ErrorMessage, (CHAR8 *) ErrInfo);
     628  AsciiStrCpyS ((CHAR8 *) TftpError->Error.ErrorMessage, AsciiStrLen ((CHAR8 *) ErrInfo) + 1 , (CHAR8 *) ErrInfo);
    588629
    589630  //
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette