+2005-06-20 Theodore Ts'o <tytso@mit.edu>
+
+ * et_c.awk: Use a dynamically allocated structure in
+ initialize_xxx_error_table(), to prevent segfaults if an
+ old library calls initialize_xxx_error_table, and another
+ library/application calls add_error_table() on the same
+ error table, and then calls remove_error_table().
+ (Addresses Sourcefroge Bug #1150146)
+
2005-03-21 Theodore Ts'o <tytso@mit.edu>
* Release of E2fsprogs 1.37
print "" > outfile
print "static struct et_list link = { 0, 0 };" > outfile
print "" > outfile
+ print "void initialize_" table_name "_error_table_r(struct et_list **list);" > outfile
print "void initialize_" table_name "_error_table(void);" > outfile
print "" > outfile
print "void initialize_" table_name "_error_table(void) {" > outfile
- print " if (!link.table) {" > outfile
- print " link.next = _et_list;" > outfile
- print " link.table = &et_" table_name "_error_table;" > outfile
- print " _et_list = &link;" > outfile
- print " }" > outfile
+ print " initialize_" table_name "_error_table_r(&_et_list);" > outfile
print "}" > outfile
print "" > outfile
print "/* For Heimdal compatibility */" > outfile
- print "void initialize_" table_name "_error_table_r(struct et_list **list);" > outfile
- print "" > outfile
print "void initialize_" table_name "_error_table_r(struct et_list **list)" > outfile
print "{" > outfile
print " struct et_list *et, **end;" > outfile
print " if (et->table->msgs == text)" > outfile
print " return;" > outfile
print " et = malloc(sizeof(struct et_list));" > outfile
- print " if (et == 0)" > outfile
- print " return;" > outfile
+ print " if (et == 0) {" > outfile
+ print " if (!link.table)" > outfile
+ print " et = &link;" > outfile
+ print " else" > outfile
+ print " return;" > outfile
+ print " }" > outfile
print " et->table = &et_" table_name "_error_table;" > outfile
print " et->next = 0;" > outfile
print " *end = et;" > outfile
static struct et_list link = { 0, 0 };
+void initialize_ovk_error_table_r(struct et_list **list);
void initialize_ovk_error_table(void);
void initialize_ovk_error_table(void) {
- if (!link.table) {
- link.next = _et_list;
- link.table = &et_ovk_error_table;
- _et_list = &link;
- }
+ initialize_ovk_error_table_r(&_et_list);
}
/* For Heimdal compatibility */
-void initialize_ovk_error_table_r(struct et_list **list);
-
void initialize_ovk_error_table_r(struct et_list **list)
{
struct et_list *et, **end;
if (et->table->msgs == text)
return;
et = malloc(sizeof(struct et_list));
- if (et == 0)
- return;
+ if (et == 0) {
+ if (!link.table)
+ et = &link;
+ else
+ return;
+ }
et->table = &et_ovk_error_table;
et->next = 0;
*end = et;
static struct et_list link = { 0, 0 };
+void initialize_krb_error_table_r(struct et_list **list);
void initialize_krb_error_table(void);
void initialize_krb_error_table(void) {
- if (!link.table) {
- link.next = _et_list;
- link.table = &et_krb_error_table;
- _et_list = &link;
- }
+ initialize_krb_error_table_r(&_et_list);
}
/* For Heimdal compatibility */
-void initialize_krb_error_table_r(struct et_list **list);
-
void initialize_krb_error_table_r(struct et_list **list)
{
struct et_list *et, **end;
if (et->table->msgs == text)
return;
et = malloc(sizeof(struct et_list));
- if (et == 0)
- return;
+ if (et == 0) {
+ if (!link.table)
+ et = &link;
+ else
+ return;
+ }
et->table = &et_krb_error_table;
et->next = 0;
*end = et;
static struct et_list link = { 0, 0 };
+void initialize_kadm_error_table_r(struct et_list **list);
void initialize_kadm_error_table(void);
void initialize_kadm_error_table(void) {
- if (!link.table) {
- link.next = _et_list;
- link.table = &et_kadm_error_table;
- _et_list = &link;
- }
+ initialize_kadm_error_table_r(&_et_list);
}
/* For Heimdal compatibility */
-void initialize_kadm_error_table_r(struct et_list **list);
-
void initialize_kadm_error_table_r(struct et_list **list)
{
struct et_list *et, **end;
if (et->table->msgs == text)
return;
et = malloc(sizeof(struct et_list));
- if (et == 0)
- return;
+ if (et == 0) {
+ if (!link.table)
+ et = &link;
+ else
+ return;
+ }
et->table = &et_kadm_error_table;
et->next = 0;
*end = et;
static struct et_list link = { 0, 0 };
+void initialize_h3test_error_table_r(struct et_list **list);
void initialize_h3test_error_table(void);
void initialize_h3test_error_table(void) {
- if (!link.table) {
- link.next = _et_list;
- link.table = &et_h3test_error_table;
- _et_list = &link;
- }
+ initialize_h3test_error_table_r(&_et_list);
}
/* For Heimdal compatibility */
-void initialize_h3test_error_table_r(struct et_list **list);
-
void initialize_h3test_error_table_r(struct et_list **list)
{
struct et_list *et, **end;
if (et->table->msgs == text)
return;
et = malloc(sizeof(struct et_list));
- if (et == 0)
- return;
+ if (et == 0) {
+ if (!link.table)
+ et = &link;
+ else
+ return;
+ }
et->table = &et_h3test_error_table;
et->next = 0;
*end = et;
static struct et_list link = { 0, 0 };
+void initialize_imap_error_table_r(struct et_list **list);
void initialize_imap_error_table(void);
void initialize_imap_error_table(void) {
- if (!link.table) {
- link.next = _et_list;
- link.table = &et_imap_error_table;
- _et_list = &link;
- }
+ initialize_imap_error_table_r(&_et_list);
}
/* For Heimdal compatibility */
-void initialize_imap_error_table_r(struct et_list **list);
-
void initialize_imap_error_table_r(struct et_list **list)
{
struct et_list *et, **end;
if (et->table->msgs == text)
return;
et = malloc(sizeof(struct et_list));
- if (et == 0)
- return;
+ if (et == 0) {
+ if (!link.table)
+ et = &link;
+ else
+ return;
+ }
et->table = &et_imap_error_table;
et->next = 0;
*end = et;
static struct et_list link = { 0, 0 };
+void initialize_krb_error_table_r(struct et_list **list);
void initialize_krb_error_table(void);
void initialize_krb_error_table(void) {
- if (!link.table) {
- link.next = _et_list;
- link.table = &et_krb_error_table;
- _et_list = &link;
- }
+ initialize_krb_error_table_r(&_et_list);
}
/* For Heimdal compatibility */
-void initialize_krb_error_table_r(struct et_list **list);
-
void initialize_krb_error_table_r(struct et_list **list)
{
struct et_list *et, **end;
if (et->table->msgs == text)
return;
et = malloc(sizeof(struct et_list));
- if (et == 0)
- return;
+ if (et == 0) {
+ if (!link.table)
+ et = &link;
+ else
+ return;
+ }
et->table = &et_krb_error_table;
et->next = 0;
*end = et;