Skip to content

Commit b2078eb

Browse files
committed
fix conflicts
Signed-off-by: Slice <[email protected]>
2 parents c557ba9 + 43ac33a commit b2078eb

File tree

29 files changed

+429
-120
lines changed

29 files changed

+429
-120
lines changed

.github/workflows/codeql.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "master" ]
17+
pull_request:
18+
branches: [ "master" ]
19+
schedule:
20+
- cron: '28 16 * * 2'
21+
22+
jobs:
23+
analyze:
24+
name: Analyze (${{ matrix.language }})
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners (GitHub.com only)
29+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
30+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31+
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
32+
permissions:
33+
# required for all workflows
34+
security-events: write
35+
36+
# required to fetch internal or private CodeQL packs
37+
packages: read
38+
39+
# only required for workflows in private repositories
40+
actions: read
41+
contents: read
42+
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
include:
47+
- language: c-cpp
48+
build-mode: autobuild
49+
- language: csharp
50+
build-mode: autobuild
51+
- language: java-kotlin
52+
build-mode: none # This mode only analyzes Java. Set this to 'autobuild' or 'manual' to analyze Kotlin too.
53+
- language: python
54+
build-mode: none
55+
- language: ruby
56+
build-mode: none
57+
- language: swift
58+
build-mode: autobuild
59+
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
60+
# Use `c-cpp` to analyze code written in C, C++ or both
61+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
62+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
63+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
64+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
65+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
66+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
67+
steps:
68+
- name: Checkout repository
69+
uses: actions/checkout@v4
70+
71+
# Initializes the CodeQL tools for scanning.
72+
- name: Initialize CodeQL
73+
uses: github/codeql-action/init@v3
74+
with:
75+
languages: ${{ matrix.language }}
76+
build-mode: ${{ matrix.build-mode }}
77+
# If you wish to specify custom queries, you can do so here or in a config file.
78+
# By default, queries listed here will override any specified in a config file.
79+
# Prefix the list here with "+" to use these queries and those in the config file.
80+
81+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
82+
# queries: security-extended,security-and-quality
83+
84+
# If the analyze step fails for one of the languages you are analyzing with
85+
# "We were unable to automatically build your code", modify the matrix above
86+
# to set the build mode to "manual" for that language. Then modify this step
87+
# to build your code.
88+
# ℹ️ Command-line programs to run using the OS shell.
89+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
90+
- if: matrix.build-mode == 'manual'
91+
shell: bash
92+
run: |
93+
echo 'If you are using a "manual" build mode for one or more of the' \
94+
'languages you are analyzing, replace this with the commands to build' \
95+
'your code, for example:'
96+
echo ' make bootstrap'
97+
echo ' make release'
98+
exit 1
99+
100+
- name: Perform CodeQL Analysis
101+
uses: github/codeql-action/analyze@v3
102+
with:
103+
category: "/language:${{matrix.language}}"
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Python Package using Conda
2+
3+
on: [push]
4+
5+
jobs:
6+
build-linux:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
max-parallel: 5
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Set up Python 3.10
14+
uses: actions/setup-python@v3
15+
with:
16+
python-version: '3.10'
17+
- name: Add conda to system path
18+
run: |
19+
# $CONDA is an environment variable pointing to the root of the miniconda directory
20+
echo $CONDA/bin >> $GITHUB_PATH
21+
- name: Install dependencies
22+
run: |
23+
conda env update --file environment.yml --name base
24+
- name: Lint with flake8
25+
run: |
26+
conda install flake8
27+
# stop the build if there are Python syntax errors or undefined names
28+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
29+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
30+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
31+
- name: Test with pytest
32+
run: |
33+
conda install pytest
34+
pytest

BaseTools/Source/C/Common/CommonLib.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ Routine Description:
526526
}
527527

528528
if (Uppercase) {
529-
sprintf (
530-
(CHAR8 *)Buffer,
529+
snprintf (
530+
(CHAR8 *)Buffer, PRINTED_GUID_BUFFER_SIZE,
531531
"%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
532532
(unsigned) Guid->Data1,
533533
Guid->Data2,
@@ -542,8 +542,8 @@ Routine Description:
542542
Guid->Data4[7]
543543
);
544544
} else {
545-
sprintf (
546-
(CHAR8 *)Buffer,
545+
snprintf (
546+
(CHAR8 *)Buffer, PRINTED_GUID_BUFFER_SIZE,
547547
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
548548
(unsigned) Guid->Data1,
549549
Guid->Data2,

BaseTools/Source/C/Common/EfiUtilityMsgs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ Routine Description:
459459
strcpy (Line, ": ");
460460
strncat (Line, Cptr, MAX_LINE_LEN - strlen (Line) - 1);
461461
if (LineNumber != 0) {
462-
sprintf (Line2, "(%u)", (unsigned) LineNumber);
462+
snprintf (Line2, MAX_LINE_LEN, "(%u)", (unsigned) LineNumber);
463463
strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);
464464
}
465465
}
@@ -474,7 +474,7 @@ Routine Description:
474474
strncpy (Line, Cptr, MAX_LINE_LEN - 1);
475475
Line[MAX_LINE_LEN - 1] = 0;
476476
if (LineNumber != 0) {
477-
sprintf (Line2, "(%u)", (unsigned) LineNumber);
477+
snprintf (Line2, MAX_LINE_LEN, "(%u)", (unsigned) LineNumber);
478478
strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);
479479
}
480480
} else {
@@ -501,7 +501,7 @@ Routine Description:
501501
strncat (Line, ": ", MAX_LINE_LEN - strlen (Line) - 1);
502502
strncat (Line, Type, MAX_LINE_LEN - strlen (Line) - 1);
503503
if (MessageCode != 0) {
504-
sprintf (Line2, " %04u", (unsigned) MessageCode);
504+
snprintf (Line2, MAX_LINE_LEN, " %04u", (unsigned) MessageCode);
505505
strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);
506506
}
507507
fprintf (stdout, "%s", Line);

BaseTools/Source/C/Common/PcdValueCommon.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,16 @@ Routine Description:
257257
}
258258
break;
259259
case PcdDataTypeUint8:
260-
sprintf(PcdList[Index].Value, "0x%02x", (UINT8)(Value & 0xff));
260+
snprintf(PcdList[Index].Value, 20, "0x%02x", (UINT8)(Value & 0xff));
261261
break;
262262
case PcdDataTypeUint16:
263-
sprintf(PcdList[Index].Value, "0x%04x", (UINT16)(Value & 0xffff));
263+
snprintf(PcdList[Index].Value, 20, "0x%04x", (UINT16)(Value & 0xffff));
264264
break;
265265
case PcdDataTypeUint32:
266-
sprintf(PcdList[Index].Value, "0x%08x", (UINT32)(Value & 0xffffffff));
266+
snprintf(PcdList[Index].Value, 20, "0x%08x", (UINT32)(Value & 0xffffffff));
267267
break;
268268
case PcdDataTypeUint64:
269-
sprintf(PcdList[Index].Value, "0x%016llx", (unsigned long long)Value);
269+
snprintf(PcdList[Index].Value, 20, "0x%016llx", (unsigned long long)Value);
270270
break;
271271
case PcdDataTypePointer:
272272
fprintf (stderr, "PCD %s.%s.%s.%s is structure. Use PcdSetPtr()\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
@@ -392,7 +392,7 @@ Routine Description:
392392
PcdList[Index].Value = malloc(Size * 5 + 3);
393393
PcdList[Index].Value[0] = '{';
394394
for (ValueIndex = 0; ValueIndex < Size; ValueIndex++) {
395-
sprintf(&PcdList[Index].Value[1 + ValueIndex * 5], "0x%02x,", Value[ValueIndex]);
395+
snprintf(&PcdList[Index].Value[1 + ValueIndex * 5], 20, "0x%02x,", Value[ValueIndex]);
396396
}
397397
PcdList[Index].Value[1 + Size * 5 - 1] = '}';
398398
PcdList[Index].Value[1 + Size * 5 ] = 0;

BaseTools/Source/C/GenFfs/GenFfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -819,13 +819,13 @@ Routine Description:
819819
goto Finish;
820820
}
821821
if (Alignment < 0x400){
822-
sprintf (AlignmentBuffer, "%d", Alignment);
822+
snprintf (AlignmentBuffer, sizeof(AlignmentBuffer), "%d", Alignment);
823823
}
824824
else if (Alignment >= 0x400) {
825825
if (Alignment >= 0x100000) {
826-
sprintf (AlignmentBuffer, "%dM", Alignment/0x100000);
826+
snprintf (AlignmentBuffer, sizeof(AlignmentBuffer),"%dM", Alignment/0x100000);
827827
} else {
828-
sprintf (AlignmentBuffer, "%dK", Alignment/0x400);
828+
snprintf (AlignmentBuffer, sizeof(AlignmentBuffer), "%dK", Alignment/0x400);
829829
}
830830
}
831831
Status = StringtoAlignment (AlignmentBuffer, &(InputFileAlign[InputFileNum]));

BaseTools/Source/C/LzmaCompress/LzmaCompress.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ int PrintError(char *buffer, const char *message)
7373

7474
int PrintErrorNumber(char *buffer, SRes val)
7575
{
76-
sprintf(buffer + strlen(buffer), "\nError code: %x\n", (unsigned)val);
76+
char text[100];
77+
snprintf(text, 100, "\nError code: %x\n", (unsigned)val);
78+
// sprintf(buffer + strlen(buffer), "\nError code: %x\n", (unsigned)val);
79+
strcat(buffer, text);
7780
return 1;
7881
}
7982

@@ -84,7 +87,10 @@ int PrintUserError(char *buffer)
8487

8588
void PrintVersion(char *buffer)
8689
{
87-
sprintf (buffer, "%s Version %d.%d %s ", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
90+
// sprintf (buffer, "%s Version %d.%d %s ", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
91+
char text[500];
92+
snprintf(text, 500, "%s Version %d.%d %s ", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
93+
strcat(buffer, text);
8894
}
8995

9096
static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize)

BaseTools/Source/C/Mtoc/mtoc-v921_jief.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ struct arch *arch)
887887
IMAGE_SCN_MEM_WRITE |
888888
IMAGE_SCN_CNT_INITIALIZED_DATA;
889889
if(strcmp(s->sectname, "__pointers") == 0){
890-
sprintf(scnhdrs[j].s_name, "/%d", strsize);
890+
snprintf(scnhdrs[j].s_name, 10, "/%d", strsize);
891891
strcat(section_name, ".pointers");
892892
len = strlen(section_name) + 1;
893893
strsize += len;
@@ -1208,7 +1208,7 @@ struct arch *arch)
12081208
s64 = (struct section_64 *)
12091209
((char *)sg64 + sizeof(struct segment_command_64));
12101210
for(i = 0; i < sg64->nsects; i++, s64++){
1211-
sprintf(scnhdrs[j].s_name, "/%d", strsize);
1211+
snprintf(scnhdrs[j].s_name, 10, "/%d", strsize);
12121212
strcat(section_name, "LC_SEGMENT.");
12131213
strcat(section_name, s64->segname);
12141214
strcat(section_name, ".");

BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,8 +2302,8 @@ TokNode *p;
23022302
p->tclass->setnum = e;
23032303
p->tclass->setnumErrSet = eErrSet; /* MR23 */
23042304
}
2305-
sprintf(buf, "%s_set", TokenString(p->token));
2306-
sprintf(bufErrSet, "%s_errset", TokenString(p->token)); /* MR23 */
2305+
snprintf(buf, sizeof(buf), "%s_set", TokenString(p->token));
2306+
snprintf(bufErrSet, sizeof(bufErrSet), "%s_errset", TokenString(p->token)); /* MR23 */
23072307
set_name = buf;
23082308
set_nameErrSet = bufErrSet; /* MR23 */
23092309
}
@@ -2325,8 +2325,8 @@ TokNode *p;
23252325
p->tclass->setnumComplement = e;
23262326
p->tclass->setnumErrSetComplement = eErrSet; /* MR23 */
23272327
}
2328-
sprintf(buf, "%s_setbar", TokenString(p->token));
2329-
sprintf(bufErrSet, "%s_errsetbar", TokenString(p->token)); /* MR23 */
2328+
snprintf(buf, sizeof(buf), "%s_setbar", TokenString(p->token));
2329+
snprintf(bufErrSet, sizeof(bufErrSet), "%s_errsetbar", TokenString(p->token)); /* MR23 */
23302330
set_name = buf;
23312331
set_nameErrSet = bufErrSet; /* MR23 */
23322332
}
@@ -2335,10 +2335,10 @@ TokNode *p;
23352335
static char bufErrSet[sizeof("zzerr")+10];
23362336
int n = DefErrSet( &b, 0, NULL );
23372337
int nErrSet = DefErrSetWithSuffix(0, &bErrSet, 1, NULL, "_set");
2338-
if ( GenCC ) sprintf(buf, "err%d", n);
2339-
else sprintf(buf, "zzerr%d", n);
2340-
if ( GenCC ) sprintf(bufErrSet, "err%d", nErrSet);
2341-
else sprintf(bufErrSet, "zzerr%d", nErrSet);
2338+
if ( GenCC ) snprintf(buf, sizeof(buf), "err%d", n);
2339+
else snprintf(buf, sizeof(buf), "zzerr%d", n);
2340+
if ( GenCC ) snprintf(bufErrSet, sizeof(bufErrSet), "err%d", nErrSet);
2341+
else snprintf(bufErrSet, sizeof(bufErrSet), "zzerr%d", nErrSet);
23422342
set_name = buf;
23432343
set_nameErrSet = bufErrSet;
23442344
}
@@ -4365,9 +4365,9 @@ TokNode *p;
43654365
n = DefErrSet( &a, 0, NULL );
43664366
set_free(a);
43674367
if ( GenCC )
4368-
sprintf(buf, "err%d", n);
4368+
snprintf(buf, 100, "err%d", n);
43694369
else
4370-
sprintf(buf, "zzerr%d", n);
4370+
snprintf(buf, 100, "zzerr%d", n);
43714371
return buf;
43724372
}
43734373

BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ char *a3;
12251225
{
12261226
static char buf[250]; /* DANGEROUS as hell !!!!!! */
12271227

1228-
sprintf(buf, s, a1, a2, a3);
1228+
snprintf(buf, 250, s, a1, a2, a3);
12291229
return( buf );
12301230
}
12311231

@@ -1241,7 +1241,7 @@ int d;
12411241
{
12421242
static char buf[250]; /* DANGEROUS as hell !!!!!! */
12431243

1244-
sprintf(buf, s, d);
1244+
snprintf(buf, 250, s, d);
12451245
return( buf );
12461246
}
12471247

@@ -1257,7 +1257,7 @@ int d2;
12571257
{
12581258
static char buf[250]; /* DANGEROUS as hell !!!!!! */
12591259

1260-
sprintf(buf, s, d1, d2);
1260+
snprintf(buf, 250, s, d1, d2);
12611261
return( buf );
12621262
}
12631263

@@ -1306,7 +1306,7 @@ int token;
13061306
}
13071307

13081308
if (1) {
1309-
sprintf(imag_name,"UnknownToken#%d",token); /* MR13 */
1309+
snprintf(imag_name, 20, "UnknownToken#%d",token); /* MR13 */
13101310
return imag_name; /* MR13 */
13111311
}
13121312

@@ -1720,7 +1720,7 @@ char *name;
17201720
{
17211721
static char buf[100];
17221722
char *p;
1723-
sprintf(buf, "%s", name);
1723+
snprintf(buf, 100, "%s", name);
17241724

17251725
for (p=buf; *p!='\0'; p++)
17261726
{
@@ -1740,7 +1740,7 @@ int altnum;
17401740
{
17411741
static char buf[100];
17421742
char *p;
1743-
sprintf(buf, "_blk%d_alt%d", blockid, altnum);
1743+
snprintf(buf, 100, "_blk%d_alt%d", blockid, altnum);
17441744
p = (char *)malloc(strlen(buf)+1);
17451745
strcpy(p, buf);
17461746
return p;

BaseTools/Source/C/VfrCompile/Pccts/antlr/mrhoist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,9 +2215,9 @@ char * MR_ruleNamePlusOffset(n)
22152215

22162216
strncpy(ruleNameStatic1,n->rname,ruleNameMax);
22172217
if (offset < 0) {
2218-
sprintf(ruleNameStatic2,"%s/?",ruleNameStatic1);
2218+
snprintf(ruleNameStatic2, sizeof(ruleNameStatic2), "%s/?",ruleNameStatic1);
22192219
} else {
2220-
sprintf(ruleNameStatic2,"%s/%d",ruleNameStatic1,offset+1);
2220+
snprintf(ruleNameStatic2, sizeof(ruleNameStatic2), "%s/%d",ruleNameStatic1,offset+1);
22212221
};
22222222
return ruleNameStatic2;
22232223
}

0 commit comments

Comments
 (0)