Hi Aaron,
could you retest with latest svn and the patch below? Thanks!
On 04.12.2008 04:41, aaron lwe wrote:
>> That's due to the rename being performed in build_opt_tbl. Renames can't
>> be done across filesystems. I saw that problem in the original patch,
>> but I didn't want to ruin the mood by complaining.
>>
>
> I see compiling errors more important than the mood.
>
>
>> Anyway, here is a patch to fix it.
>>
>> Signed-off-by: Carl-Daniel Hailfinger <[EMAIL PROTECTED]>
>>
>
> The patch works well for me and is much better than the statically
> allocated method which will probablly cause other people complain due
> to their very long path name.
>
> Acked-by: Aaron Lwe <[EMAIL PROTECTED]>
>
Fix a few bugs introduced in r3789.
- Possible NULL pointer dereference in the header code because the
header code incorrectly used the option filename instead of the header
filename.
- Breakage if the path is longer than 234 bytes.
Signed-off-by: Carl-Daniel Hailfinger <[EMAIL PROTECTED]>
Index: LinuxBIOSv2-build_opt_tbl/util/options/build_opt_tbl.c
===================================================================
--- LinuxBIOSv2-build_opt_tbl/util/options/build_opt_tbl.c (Revision 3794)
+++ LinuxBIOSv2-build_opt_tbl/util/options/build_opt_tbl.c (Arbeitskopie)
@@ -12,7 +12,6 @@
#define INPUT_LINE_MAX 256
#define MAX_VALUE_BYTE_LENGTH 64
-#define TMPFILE_LEN 256
#define TMPFILE_TEMPLATE "/build_opt_tbl_XXXXXX"
static unsigned char cmos_table[4096];
@@ -217,7 +216,7 @@
char *header=0;
FILE *fp;
int tmpfile;
- char tmpfilename[TMPFILE_LEN];
+ char *tmpfilename;
struct cmos_option_table *ct;
struct cmos_entries *ce;
struct cmos_enums *c_enums, *c_enums_start;
@@ -487,8 +486,9 @@
/* See if we want to output a C source file */
if(option) {
- strncpy(tmpfilename, dirname(option), TMPFILE_LEN);
- strncat(tmpfilename, TMPFILE_TEMPLATE, TMPFILE_LEN);
+ tmpfilename = malloc(strlen(dirname(option)) +
strlen(TMPFILE_TEMPLATE) + 1);
+ strcpy(tmpfilename, dirname(option));
+ strcat(tmpfilename, TMPFILE_TEMPLATE);
tmpfile = mkstemp(tmpfilename);
if(tmpfile == -1) {
perror("Error - Could not create temporary file");
@@ -531,6 +531,7 @@
unlink(tmpfilename);
exit(1);
}
+ free(tmpfilename);
}
/* See if we also want to output a C header file */
@@ -538,8 +539,9 @@
struct cmos_option_table *hdr;
struct lb_record *ptr, *end;
- strncpy(tmpfilename, dirname(option), TMPFILE_LEN);
- strncat(tmpfilename, TMPFILE_TEMPLATE, TMPFILE_LEN);
+ tmpfilename = malloc(strlen(dirname(header)) +
strlen(TMPFILE_TEMPLATE) + 1);
+ strcpy(tmpfilename, dirname(header));
+ strcat(tmpfilename, TMPFILE_TEMPLATE);
tmpfile = mkstemp(tmpfilename);
if(tmpfile == -1) {
perror("Error - Could not create temporary file");
@@ -586,6 +588,7 @@
unlink(tmpfilename);
exit(1);
}
+ free(tmpfilename);
}
return(0);
}
--
http://www.hailfinger.org/
Index: LinuxBIOSv2-build_opt_tbl/util/options/build_opt_tbl.c
===================================================================
--- LinuxBIOSv2-build_opt_tbl/util/options/build_opt_tbl.c (Revision 3794)
+++ LinuxBIOSv2-build_opt_tbl/util/options/build_opt_tbl.c (Arbeitskopie)
@@ -12,7 +12,6 @@
#define INPUT_LINE_MAX 256
#define MAX_VALUE_BYTE_LENGTH 64
-#define TMPFILE_LEN 256
#define TMPFILE_TEMPLATE "/build_opt_tbl_XXXXXX"
static unsigned char cmos_table[4096];
@@ -217,7 +216,7 @@
char *header=0;
FILE *fp;
int tmpfile;
- char tmpfilename[TMPFILE_LEN];
+ char *tmpfilename;
struct cmos_option_table *ct;
struct cmos_entries *ce;
struct cmos_enums *c_enums, *c_enums_start;
@@ -487,8 +486,9 @@
/* See if we want to output a C source file */
if(option) {
- strncpy(tmpfilename, dirname(option), TMPFILE_LEN);
- strncat(tmpfilename, TMPFILE_TEMPLATE, TMPFILE_LEN);
+ tmpfilename = malloc(strlen(dirname(option)) + strlen(TMPFILE_TEMPLATE) + 1);
+ strcpy(tmpfilename, dirname(option));
+ strcat(tmpfilename, TMPFILE_TEMPLATE);
tmpfile = mkstemp(tmpfilename);
if(tmpfile == -1) {
perror("Error - Could not create temporary file");
@@ -531,6 +531,7 @@
unlink(tmpfilename);
exit(1);
}
+ free(tmpfilename);
}
/* See if we also want to output a C header file */
@@ -538,8 +539,9 @@
struct cmos_option_table *hdr;
struct lb_record *ptr, *end;
- strncpy(tmpfilename, dirname(option), TMPFILE_LEN);
- strncat(tmpfilename, TMPFILE_TEMPLATE, TMPFILE_LEN);
+ tmpfilename = malloc(strlen(dirname(header)) + strlen(TMPFILE_TEMPLATE) + 1);
+ strcpy(tmpfilename, dirname(header));
+ strcat(tmpfilename, TMPFILE_TEMPLATE);
tmpfile = mkstemp(tmpfilename);
if(tmpfile == -1) {
perror("Error - Could not create temporary file");
@@ -586,6 +588,7 @@
unlink(tmpfilename);
exit(1);
}
+ free(tmpfilename);
}
return(0);
}
--
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot