Chameleon

Chameleon Commit Details

Date:2014-01-07 09:16:01 (10 years 3 months ago)
Author:Chuck Fry
Commit:2297
Parents: 2296
Message:search_and_get_acpi_fd: fix pointer-to-temporary return problem; use snprintf instead of sprintf to prevent buffer overflows
Changes:
M/branches/chucko/i386/libsaio/acpi_patcher.c

File differences

branches/chucko/i386/libsaio/acpi_patcher.c
9393
9494
9595
96
9697
9798
9899
99
100
100101
101102
102103
103
104
104105
105106
106
107
108
109
107
108
109
110
110111
111
112
113
112
113
114
114115
115
116
117
116
117
118
118119
119120
120121
121122
122
123
124
125
126
127
128
129
130
131123
132124
133125
......
870862
871863
872864
873
865
874866
875867
876868
}
/* The folowing ACPI Table search algo. should be reused anywhere needed:*/
/* WARNING: outDirspec string will be overwritten by subsequent calls! */
int search_and_get_acpi_fd(const char * filename, const char ** outDirspec)
{
int fd = 0;
char dirSpec[512];
static char dirSpec[512];
// Try finding 'filename' in the usual places
// Start searching any potential location for ACPI Table
sprintf(dirSpec, "%s", filename);
snprintf(dirSpec, sizeof(dirSpec), "%s", filename);
fd = open(dirSpec, 0);
if (fd < 0)
{
sprintf(dirSpec, "/Extra/%s", filename);
fd = open(dirSpec, 0);
if (fd < 0)
{
snprintf(dirSpec, sizeof(dirSpec), "/Extra/%s", filename);
fd = open(dirSpec, 0);
if (fd < 0)
{
sprintf(dirSpec, "bt(0,0)/Extra/%s", filename);
fd = open(dirSpec, 0);
if (fd < 0)
snprintf(dirSpec, sizeof(dirSpec), "bt(0,0)/Extra/%s", filename);
fd = open(dirSpec, 0);
if (fd < 0)
{
// NOT FOUND:
verbose("ACPI Table not found: %s\n", filename);
*dirSpec = '\0';
// NOT FOUND:
verbose("ACPI Table not found: %s\n", filename);
*dirSpec = '\0';
}
}
}
// Bungo
/*** Moved above
if (fd < 0)
{
// NOT FOUND:
verbose("ACPI Table not found: %s\n", filename);
*dirSpec = '\0';
}
***/
if (outDirspec) *outDirspec = dirSpec;
return fd;
}
/* Try using the file specified with the DSDT option */
if (getValueForKey(kDSDT, &filename, &len, &bootInfo->chameleonConfig))
{
sprintf(dirSpec, filename);
snprintf(dirSpec, sizeof(dirSpec), filename);
}
else
{

Archive Download the corresponding diff file

Revision: 2297