From c11325fc2c532ddd26996560fd053da65022da62 Mon Sep 17 00:00:00 2001 From: Al Stone Date: Thu, 15 Mar 2018 13:06:56 -0600 Subject: [PATCH] Clean up some of the compiler warnings about truncated strings Signed-off-by: Al Stone --- acpica-tools.spec | 3 ++ str-trunc-warn.patch | 112 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 str-trunc-warn.patch diff --git a/acpica-tools.spec b/acpica-tools.spec index 4c10b59..255161a 100644 --- a/acpica-tools.spec +++ b/acpica-tools.spec @@ -39,6 +39,7 @@ Patch12: mips-be-fix.patch Patch13: cve-2017-13693.patch Patch14: cve-2017-13694.patch Patch15: cve-2017-13695.patch +Patch16: str-trunc-warn.patch BuildRequires: bison patchutils flex gcc @@ -104,6 +105,7 @@ gzip -dc %{SOURCE1} | tar -x --strip-components=1 -f - %patch13 -p1 -b .cve-2017-13693 %patch14 -p1 -b .cve-2017-13694 %patch15 -p1 -b .cve-2017-13695 +%patch16 -p1 -b .str-trunc-warn cp -p %{SOURCE2} README.Fedora cp -p %{SOURCE3} iasl.1 @@ -249,6 +251,7 @@ fi made the wrong assumptions about what generate/unix/Makefile.config did with that value. Added to the spec file what should happen so that a full and complete set of C flags get passed in, not just the small subset that was. +- Clean up compiler warnings for truncated strings * Fri Feb 09 2018 Igor Gnatenko - 20180105-3 - Escape macros in %%changelog diff --git a/str-trunc-warn.patch b/str-trunc-warn.patch new file mode 100644 index 0000000..badf721 --- /dev/null +++ b/str-trunc-warn.patch @@ -0,0 +1,112 @@ +Index: acpica-unix2-20180209/source/compiler/aslanalyze.c +=================================================================== +--- acpica-unix2-20180209.orig/source/compiler/aslanalyze.c ++++ acpica-unix2-20180209/source/compiler/aslanalyze.c +@@ -355,11 +355,16 @@ AnCheckMethodReturnValue ( + */ + if (ThisNodeBtype != 0) + { +- sprintf (MsgBuffer, ++ int cnt; ++ char *strp; ++ ++ cnt = asprintf (&strp, + "Method returns [%s], %s operator requires [%s]", + StringBuffer, OpInfo->Name, StringBuffer2); + +- AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, MsgBuffer); ++ AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, strp); ++ if (cnt > 0) ++ free(strp); + } + } + } +Index: acpica-unix2-20180209/source/compiler/aslpredef.c +=================================================================== +--- acpica-unix2-20180209.orig/source/compiler/aslpredef.c ++++ acpica-unix2-20180209/source/compiler/aslpredef.c +@@ -159,14 +159,19 @@ ApCheckForPredefinedMethod ( + if (MethodInfo->NumReturnNoValue && + ThisName->Info.ExpectedBtypes) + { ++ int cnt; ++ char *strp; ++ + AcpiUtGetExpectedReturnTypes (StringBuffer, + ThisName->Info.ExpectedBtypes); + +- sprintf (MsgBuffer, "%s required for %4.4s", +- StringBuffer, ThisName->Info.Name); ++ cnt = asprintf (&strp, "%s required for %4.4s", ++ StringBuffer, ThisName->Info.Name); + + AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op, +- MsgBuffer); ++ strp); ++ if (cnt > 0) ++ free(strp); + } + break; + } +@@ -698,18 +703,26 @@ TypeErrorExit: + + AcpiUtGetExpectedReturnTypes (StringBuffer, ExpectedBtypes); + +- if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) +- { +- sprintf (MsgBuffer, "%4.4s: found %s, %s required", +- PredefinedName, TypeName, StringBuffer); +- } +- else + { +- sprintf (MsgBuffer, "%4.4s: found %s at index %u, %s required", +- PredefinedName, TypeName, PackageIndex, StringBuffer); ++ int cnt; ++ char *strp; ++ ++ if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT) ++ { ++ cnt = asprintf (&strp, "%4.4s: found %s, %s required", ++ PredefinedName, TypeName, StringBuffer); ++ } ++ else ++ { ++ cnt = asprintf (&strp, "%4.4s: found %s at index %u, %s required", ++ PredefinedName, TypeName, PackageIndex, StringBuffer); ++ } ++ ++ if (cnt > 0) ++ free(strp); ++ AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, strp); + } + +- AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, MsgBuffer); + return (AE_TYPE); + } + +Index: acpica-unix2-20180209/source/compiler/aslwalks.c +=================================================================== +--- acpica-unix2-20180209.orig/source/compiler/aslwalks.c ++++ acpica-unix2-20180209/source/compiler/aslwalks.c +@@ -507,15 +507,19 @@ AnOperandTypecheckWalkEnd ( + else if (!CommonBtypes) + { + /* No match -- this is a type mismatch error */ ++ int cnt; ++ char *strp; + + AnFormatBtype (StringBuffer, ThisNodeBtype); + AnFormatBtype (StringBuffer2, RequiredBtypes); + +- sprintf (MsgBuffer, "[%s] found, %s operator requires [%s]", ++ cnt = asprintf (&strp, "[%s] found, %s operator requires [%s]", + StringBuffer, OpInfo->Name, StringBuffer2); + + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, +- ArgOp, MsgBuffer); ++ ArgOp, strp); ++ if (cnt > 0) ++ free(strp); + } + + NextArgument: