Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: Slice <sergey.slice@gmail.com>
  • Loading branch information
SergeySlice committed Jun 25, 2024
2 parents c557ba9 + 43ac33a commit b2078eb
Show file tree
Hide file tree
Showing 29 changed files with 429 additions and 120 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: '28 16 * * 2'

jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (github.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
include:
- language: c-cpp
build-mode: autobuild
- language: csharp
build-mode: autobuild
- language: java-kotlin
build-mode: none # This mode only analyzes Java. Set this to 'autobuild' or 'manual' to analyze Kotlin too.
- language: python
build-mode: none
- language: ruby
build-mode: none
- language: swift
build-mode: autobuild
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# 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
steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# 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
# queries: security-extended,security-and-quality

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
34 changes: 34 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Python Package using Conda

on: [push]

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda env update --file environment.yml --name base
- name: Lint with flake8
run: |
conda install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
conda install pytest
pytest
8 changes: 4 additions & 4 deletions BaseTools/Source/C/Common/CommonLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ Routine Description:
}

if (Uppercase) {
sprintf (
(CHAR8 *)Buffer,
snprintf (
(CHAR8 *)Buffer, PRINTED_GUID_BUFFER_SIZE,
"%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
(unsigned) Guid->Data1,
Guid->Data2,
Expand All @@ -542,8 +542,8 @@ Routine Description:
Guid->Data4[7]
);
} else {
sprintf (
(CHAR8 *)Buffer,
snprintf (
(CHAR8 *)Buffer, PRINTED_GUID_BUFFER_SIZE,
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
(unsigned) Guid->Data1,
Guid->Data2,
Expand Down
6 changes: 3 additions & 3 deletions BaseTools/Source/C/Common/EfiUtilityMsgs.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ Routine Description:
strcpy (Line, ": ");
strncat (Line, Cptr, MAX_LINE_LEN - strlen (Line) - 1);
if (LineNumber != 0) {
sprintf (Line2, "(%u)", (unsigned) LineNumber);
snprintf (Line2, MAX_LINE_LEN, "(%u)", (unsigned) LineNumber);
strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);
}
}
Expand All @@ -474,7 +474,7 @@ Routine Description:
strncpy (Line, Cptr, MAX_LINE_LEN - 1);
Line[MAX_LINE_LEN - 1] = 0;
if (LineNumber != 0) {
sprintf (Line2, "(%u)", (unsigned) LineNumber);
snprintf (Line2, MAX_LINE_LEN, "(%u)", (unsigned) LineNumber);
strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);
}
} else {
Expand All @@ -501,7 +501,7 @@ Routine Description:
strncat (Line, ": ", MAX_LINE_LEN - strlen (Line) - 1);
strncat (Line, Type, MAX_LINE_LEN - strlen (Line) - 1);
if (MessageCode != 0) {
sprintf (Line2, " %04u", (unsigned) MessageCode);
snprintf (Line2, MAX_LINE_LEN, " %04u", (unsigned) MessageCode);
strncat (Line, Line2, MAX_LINE_LEN - strlen (Line) - 1);
}
fprintf (stdout, "%s", Line);
Expand Down
10 changes: 5 additions & 5 deletions BaseTools/Source/C/Common/PcdValueCommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,16 @@ Routine Description:
}
break;
case PcdDataTypeUint8:
sprintf(PcdList[Index].Value, "0x%02x", (UINT8)(Value & 0xff));
snprintf(PcdList[Index].Value, 20, "0x%02x", (UINT8)(Value & 0xff));
break;
case PcdDataTypeUint16:
sprintf(PcdList[Index].Value, "0x%04x", (UINT16)(Value & 0xffff));
snprintf(PcdList[Index].Value, 20, "0x%04x", (UINT16)(Value & 0xffff));
break;
case PcdDataTypeUint32:
sprintf(PcdList[Index].Value, "0x%08x", (UINT32)(Value & 0xffffffff));
snprintf(PcdList[Index].Value, 20, "0x%08x", (UINT32)(Value & 0xffffffff));
break;
case PcdDataTypeUint64:
sprintf(PcdList[Index].Value, "0x%016llx", (unsigned long long)Value);
snprintf(PcdList[Index].Value, 20, "0x%016llx", (unsigned long long)Value);
break;
case PcdDataTypePointer:
fprintf (stderr, "PCD %s.%s.%s.%s is structure. Use PcdSetPtr()\n", SkuName, DefaultValueName, TokenSpaceGuidName, TokenName);
Expand Down Expand Up @@ -392,7 +392,7 @@ Routine Description:
PcdList[Index].Value = malloc(Size * 5 + 3);
PcdList[Index].Value[0] = '{';
for (ValueIndex = 0; ValueIndex < Size; ValueIndex++) {
sprintf(&PcdList[Index].Value[1 + ValueIndex * 5], "0x%02x,", Value[ValueIndex]);
snprintf(&PcdList[Index].Value[1 + ValueIndex * 5], 20, "0x%02x,", Value[ValueIndex]);
}
PcdList[Index].Value[1 + Size * 5 - 1] = '}';
PcdList[Index].Value[1 + Size * 5 ] = 0;
Expand Down
6 changes: 3 additions & 3 deletions BaseTools/Source/C/GenFfs/GenFfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,13 +819,13 @@ Routine Description:
goto Finish;
}
if (Alignment < 0x400){
sprintf (AlignmentBuffer, "%d", Alignment);
snprintf (AlignmentBuffer, sizeof(AlignmentBuffer), "%d", Alignment);
}
else if (Alignment >= 0x400) {
if (Alignment >= 0x100000) {
sprintf (AlignmentBuffer, "%dM", Alignment/0x100000);
snprintf (AlignmentBuffer, sizeof(AlignmentBuffer),"%dM", Alignment/0x100000);
} else {
sprintf (AlignmentBuffer, "%dK", Alignment/0x400);
snprintf (AlignmentBuffer, sizeof(AlignmentBuffer), "%dK", Alignment/0x400);
}
}
Status = StringtoAlignment (AlignmentBuffer, &(InputFileAlign[InputFileNum]));
Expand Down
10 changes: 8 additions & 2 deletions BaseTools/Source/C/LzmaCompress/LzmaCompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ int PrintError(char *buffer, const char *message)

int PrintErrorNumber(char *buffer, SRes val)
{
sprintf(buffer + strlen(buffer), "\nError code: %x\n", (unsigned)val);
char text[100];
snprintf(text, 100, "\nError code: %x\n", (unsigned)val);
// sprintf(buffer + strlen(buffer), "\nError code: %x\n", (unsigned)val);
strcat(buffer, text);
return 1;
}

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

void PrintVersion(char *buffer)
{
sprintf (buffer, "%s Version %d.%d %s ", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
// sprintf (buffer, "%s Version %d.%d %s ", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
char text[500];
snprintf(text, 500, "%s Version %d.%d %s ", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
strcat(buffer, text);
}

static SRes Encode(ISeqOutStream *outStream, ISeqInStream *inStream, UInt64 fileSize)
Expand Down
4 changes: 2 additions & 2 deletions BaseTools/Source/C/Mtoc/mtoc-v921_jief.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ struct arch *arch)
IMAGE_SCN_MEM_WRITE |
IMAGE_SCN_CNT_INITIALIZED_DATA;
if(strcmp(s->sectname, "__pointers") == 0){
sprintf(scnhdrs[j].s_name, "/%d", strsize);
snprintf(scnhdrs[j].s_name, 10, "/%d", strsize);
strcat(section_name, ".pointers");
len = strlen(section_name) + 1;
strsize += len;
Expand Down Expand Up @@ -1208,7 +1208,7 @@ struct arch *arch)
s64 = (struct section_64 *)
((char *)sg64 + sizeof(struct segment_command_64));
for(i = 0; i < sg64->nsects; i++, s64++){
sprintf(scnhdrs[j].s_name, "/%d", strsize);
snprintf(scnhdrs[j].s_name, 10, "/%d", strsize);
strcat(section_name, "LC_SEGMENT.");
strcat(section_name, s64->segname);
strcat(section_name, ".");
Expand Down
20 changes: 10 additions & 10 deletions BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2302,8 +2302,8 @@ TokNode *p;
p->tclass->setnum = e;
p->tclass->setnumErrSet = eErrSet; /* MR23 */
}
sprintf(buf, "%s_set", TokenString(p->token));
sprintf(bufErrSet, "%s_errset", TokenString(p->token)); /* MR23 */
snprintf(buf, sizeof(buf), "%s_set", TokenString(p->token));
snprintf(bufErrSet, sizeof(bufErrSet), "%s_errset", TokenString(p->token)); /* MR23 */
set_name = buf;
set_nameErrSet = bufErrSet; /* MR23 */
}
Expand All @@ -2325,8 +2325,8 @@ TokNode *p;
p->tclass->setnumComplement = e;
p->tclass->setnumErrSetComplement = eErrSet; /* MR23 */
}
sprintf(buf, "%s_setbar", TokenString(p->token));
sprintf(bufErrSet, "%s_errsetbar", TokenString(p->token)); /* MR23 */
snprintf(buf, sizeof(buf), "%s_setbar", TokenString(p->token));
snprintf(bufErrSet, sizeof(bufErrSet), "%s_errsetbar", TokenString(p->token)); /* MR23 */
set_name = buf;
set_nameErrSet = bufErrSet; /* MR23 */
}
Expand All @@ -2335,10 +2335,10 @@ TokNode *p;
static char bufErrSet[sizeof("zzerr")+10];
int n = DefErrSet( &b, 0, NULL );
int nErrSet = DefErrSetWithSuffix(0, &bErrSet, 1, NULL, "_set");
if ( GenCC ) sprintf(buf, "err%d", n);
else sprintf(buf, "zzerr%d", n);
if ( GenCC ) sprintf(bufErrSet, "err%d", nErrSet);
else sprintf(bufErrSet, "zzerr%d", nErrSet);
if ( GenCC ) snprintf(buf, sizeof(buf), "err%d", n);
else snprintf(buf, sizeof(buf), "zzerr%d", n);
if ( GenCC ) snprintf(bufErrSet, sizeof(bufErrSet), "err%d", nErrSet);
else snprintf(bufErrSet, sizeof(bufErrSet), "zzerr%d", nErrSet);
set_name = buf;
set_nameErrSet = bufErrSet;
}
Expand Down Expand Up @@ -4365,9 +4365,9 @@ TokNode *p;
n = DefErrSet( &a, 0, NULL );
set_free(a);
if ( GenCC )
sprintf(buf, "err%d", n);
snprintf(buf, 100, "err%d", n);
else
sprintf(buf, "zzerr%d", n);
snprintf(buf, 100, "zzerr%d", n);
return buf;
}

Expand Down
12 changes: 6 additions & 6 deletions BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ char *a3;
{
static char buf[250]; /* DANGEROUS as hell !!!!!! */

sprintf(buf, s, a1, a2, a3);
snprintf(buf, 250, s, a1, a2, a3);
return( buf );
}

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

sprintf(buf, s, d);
snprintf(buf, 250, s, d);
return( buf );
}

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

sprintf(buf, s, d1, d2);
snprintf(buf, 250, s, d1, d2);
return( buf );
}

Expand Down Expand Up @@ -1306,7 +1306,7 @@ int token;
}

if (1) {
sprintf(imag_name,"UnknownToken#%d",token); /* MR13 */
snprintf(imag_name, 20, "UnknownToken#%d",token); /* MR13 */
return imag_name; /* MR13 */
}

Expand Down Expand Up @@ -1720,7 +1720,7 @@ char *name;
{
static char buf[100];
char *p;
sprintf(buf, "%s", name);
snprintf(buf, 100, "%s", name);

for (p=buf; *p!='\0'; p++)
{
Expand All @@ -1740,7 +1740,7 @@ int altnum;
{
static char buf[100];
char *p;
sprintf(buf, "_blk%d_alt%d", blockid, altnum);
snprintf(buf, 100, "_blk%d_alt%d", blockid, altnum);
p = (char *)malloc(strlen(buf)+1);
strcpy(p, buf);
return p;
Expand Down
4 changes: 2 additions & 2 deletions BaseTools/Source/C/VfrCompile/Pccts/antlr/mrhoist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2215,9 +2215,9 @@ char * MR_ruleNamePlusOffset(n)

strncpy(ruleNameStatic1,n->rname,ruleNameMax);
if (offset < 0) {
sprintf(ruleNameStatic2,"%s/?",ruleNameStatic1);
snprintf(ruleNameStatic2, sizeof(ruleNameStatic2), "%s/?",ruleNameStatic1);
} else {
sprintf(ruleNameStatic2,"%s/%d",ruleNameStatic1,offset+1);
snprintf(ruleNameStatic2, sizeof(ruleNameStatic2), "%s/%d",ruleNameStatic1,offset+1);
};
return ruleNameStatic2;
}
Expand Down
Loading

0 comments on commit b2078eb

Please sign in to comment.