]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/Clipboard.c
pointer verification (not NULL) and buffer overrun fixes.
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / HexEdit / Clipboard.c
1 /** @file
2 Functions to deal with Clip Board
3
4 Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include "HexEditor.h"
16
17 HEFI_EDITOR_CLIPBOARD HClipBoard;
18
19 //
20 // for basic initialization of HClipBoard
21 //
22 HEFI_EDITOR_CLIPBOARD HClipBoardConst = {
23 NULL,
24 0
25 };
26
27 EFI_STATUS
28 HClipBoardInit (
29 VOID
30 )
31 /*++
32
33 Routine Description:
34
35 Initialization function for HDiskImage
36
37 Arguments:
38
39 None
40
41 Returns:
42
43 EFI_SUCCESS
44 EFI_LOAD_ERROR
45
46 --*/
47 {
48 //
49 // basiclly initialize the HDiskImage
50 //
51 CopyMem (&HClipBoard, &HClipBoardConst, sizeof (HClipBoard));
52
53 return EFI_SUCCESS;
54 }
55
56 EFI_STATUS
57 HClipBoardCleanup (
58 VOID
59 )
60 /*++
61
62 Routine Description:
63
64 Initialization function for HDiskImage
65
66 Arguments:
67
68 None
69
70 Returns:
71
72 EFI_SUCCESS
73 EFI_LOAD_ERROR
74
75 --*/
76 {
77
78 SHELL_FREE_NON_NULL (HClipBoard.Buffer);
79
80 return EFI_SUCCESS;
81 }
82
83 EFI_STATUS
84 HClipBoardSet (
85 IN UINT8 *Buffer,
86 IN UINTN Size
87 )
88 {
89 //
90 // free the old clipboard buffer
91 // and set new clipboard buffer
92 //
93 SHELL_FREE_NON_NULL (HClipBoard.Buffer);
94 HClipBoard.Buffer = Buffer;
95
96 HClipBoard.Size = Size;
97
98 return EFI_SUCCESS;
99 }
100
101 UINTN
102 HClipBoardGet (
103 OUT UINT8 **Buffer
104 )
105 {
106 //
107 // return the clipboard buffer
108 //
109 *Buffer = HClipBoard.Buffer;
110
111 return HClipBoard.Size;
112 }