forked from acidanthera/OpenCorePkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMp3.c
87 lines (73 loc) · 1.95 KB
/
Mp3.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/** @file
Copyright (C) 2018, vit9696. All rights reserved.
All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcMp3Lib.h>
#include <Library/OcMiscLib.h>
#include <string.h>
#include <sys/time.h>
#include <stdio.h>
#include <stdint.h>
#include <UserFile.h>
int ENTRY_POINT(int argc, char** argv) {
uint32_t size;
uint8_t *buffer;
if ((buffer = UserReadFile(argc > 1 ? argv[1] : "test.mp3", &size)) == NULL) {
printf("Read fail\n");
return -1;
}
void *outbuffer;
uint32_t outsize;
EFI_AUDIO_IO_PROTOCOL_FREQ freq;
EFI_AUDIO_IO_PROTOCOL_BITS bits;
UINT8 channels;
EFI_STATUS Status = OcDecodeMp3 (
buffer,
size,
&outbuffer,
&outsize,
&freq,
&bits,
&channels
);
FreePool(buffer);
if (!EFI_ERROR (Status)) {
printf("Decode success %u\n", outsize);
UserWriteFile("test.bin", outbuffer, outsize);
FreePool(outbuffer);
return 0;
}
DEBUG ((DEBUG_WARN, "Decode failure - %r\n", Status));
return 1;
}
INT32 LLVMFuzzerTestOneInput(CONST UINT8 *Data, UINTN Size) {
if (Size > 0) {
void *outbuffer;
uint32_t outsize;
EFI_AUDIO_IO_PROTOCOL_FREQ freq;
EFI_AUDIO_IO_PROTOCOL_BITS bits;
UINT8 channels;
EFI_STATUS Status = OcDecodeMp3 (
Data,
Size,
&outbuffer,
&outsize,
&freq,
&bits,
&channels
);
if (!EFI_ERROR (Status)) {
FreePool(outbuffer);
}
}
return 0;
}