Debian Codegraph @

debian/patches/str-trunc-warn.patch

raw
1 Use dynamic memory formatting (asprintf + free) for ASL compiler warnings/errors to avoid fixed buffer usage.
2
3 Index: acpica-unix-20221020/source/compiler/aslanalyze.c
4 ===================================================================
5 --- acpica-unix-20221020.orig/source/compiler/aslanalyze.c
6 +++ acpica-unix-20221020/source/compiler/aslanalyze.c
7 @@ -466,11 +466,16 @@ AnCheckMethodReturnValue (
8 */
9 if (ThisNodeBtype != 0)
10 {
11 - sprintf (AslGbl_MsgBuffer,
12 + int cnt;
13 + char *strp;
14 +
15 + cnt = asprintf (&strp,
16 "Method returns [%s], %s operator requires [%s]",
17 AslGbl_StringBuffer, OpInfo->Name, AslGbl_StringBuffer2);
18
19 - AslError (ASL_WARNING, ASL_MSG_INVALID_TYPE, ArgOp, AslGbl_MsgBuffer);
20 + AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgOp, strp);
21 + if (cnt > 0)
22 + free(strp);
23 }
24 }
25
26 Index: acpica-unix-20221020/source/compiler/aslpredef.c
27 ===================================================================
28 --- acpica-unix-20221020.orig/source/compiler/aslpredef.c
29 +++ acpica-unix-20221020/source/compiler/aslpredef.c
30 @@ -267,14 +267,19 @@ ApCheckForPredefinedMethod (
31 if (MethodInfo->NumReturnNoValue &&
32 ThisName->Info.ExpectedBtypes)
33 {
34 + int cnt;
35 + char *strp;
36 +
37 AcpiUtGetExpectedReturnTypes (AslGbl_StringBuffer,
38 ThisName->Info.ExpectedBtypes);
39
40 - sprintf (AslGbl_MsgBuffer, "%s required for %4.4s",
41 - AslGbl_StringBuffer, ThisName->Info.Name);
42 + cnt = asprintf (&strp, "%s required for %4.4s",
43 + AslGbl_StringBuffer, ThisName->Info.Name);
44
45 AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op,
46 - AslGbl_MsgBuffer);
47 + strp);
48 + if (cnt > 0)
49 + free(strp);
50 }
51 break;
52 }
53 @@ -806,18 +811,26 @@ TypeErrorExit:
54
55 AcpiUtGetExpectedReturnTypes (AslGbl_StringBuffer, ExpectedBtypes);
56
57 - if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)
58 - {
59 - sprintf (AslGbl_MsgBuffer, "%4.4s: found %s, %s required",
60 - PredefinedName, TypeName, AslGbl_StringBuffer);
61 - }
62 - else
63 {
64 - sprintf (AslGbl_MsgBuffer, "%4.4s: found %s at index %u, %s required",
65 - PredefinedName, TypeName, PackageIndex, AslGbl_StringBuffer);
66 + int cnt;
67 + char *strp;
68 +
69 + if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)
70 + {
71 + cnt = asprintf (&strp, "%4.4s: found %s, %s required",
72 + PredefinedName, TypeName, AslGbl_StringBuffer);
73 + }
74 + else
75 + {
76 + cnt = asprintf (&strp, "%4.4s: found %s at index %u, %s required",
77 + PredefinedName, TypeName, PackageIndex, AslGbl_StringBuffer);
78 + }
79 +
80 + AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, strp);
81 + if (cnt > 0)
82 + free(strp);
83 }
84
85 - AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, AslGbl_MsgBuffer);
86 return (AE_TYPE);
87 }
88
89 Index: acpica-unix-20221020/source/compiler/aslwalks.c
90 ===================================================================
91 --- acpica-unix-20221020.orig/source/compiler/aslwalks.c
92 +++ acpica-unix-20221020/source/compiler/aslwalks.c
93 @@ -623,15 +623,19 @@ AnOperandTypecheckWalkEnd (
94 else if (!CommonBtypes)
95 {
96 /* No match -- this is a type mismatch error */
97 + int cnt;
98 + char *strp;
99
100 AnFormatBtype (AslGbl_StringBuffer, ThisNodeBtype);
101 AnFormatBtype (AslGbl_StringBuffer2, RequiredBtypes);
102
103 - sprintf (AslGbl_MsgBuffer, "[%s] found, %s operator requires [%s]",
104 + cnt = asprintf (&strp, "[%s] found, %s operator requires [%s]",
105 AslGbl_StringBuffer, OpInfo->Name, AslGbl_StringBuffer2);
106
107 AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE,
108 - ArgOp, AslGbl_MsgBuffer);
109 + ArgOp, strp);
110 + if (cnt > 0)
111 + free(strp);
112 }
113
114 NextArgument: