summaryrefslogtreecommitdiff
path: root/lib/et
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2005-06-20 16:24:04 -0400
committerTheodore Ts'o <tytso@mit.edu>2005-06-20 16:24:04 -0400
commite7d32fcb567b2a716de87204542ecc1d5e9ae1ae (patch)
treefdaea69f48d561df7b8d439e6138dd84f6437538 /lib/et
parentbb145b01cf5fd27d9afe03c3262d0e1a326e7ec1 (diff)
downloade2fsprogs-e7d32fcb567b2a716de87204542ecc1d5e9ae1ae.tar.gz
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)
Diffstat (limited to 'lib/et')
-rw-r--r--lib/et/ChangeLog9
-rw-r--r--lib/et/et_c.awk17
-rw-r--r--lib/et/test_cases/continuation.c17
-rw-r--r--lib/et/test_cases/heimdal.c17
-rw-r--r--lib/et/test_cases/heimdal2.c17
-rw-r--r--lib/et/test_cases/heimdal3.c17
-rw-r--r--lib/et/test_cases/imap_err.c17
-rw-r--r--lib/et/test_cases/simple.c17
8 files changed, 65 insertions, 63 deletions
diff --git a/lib/et/ChangeLog b/lib/et/ChangeLog
index 4bfb0d33..aa4880f8 100644
--- a/lib/et/ChangeLog
+++ b/lib/et/ChangeLog
@@ -1,3 +1,12 @@
+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
diff --git a/lib/et/et_c.awk b/lib/et/et_c.awk
index 1769b79a..407c43cc 100644
--- a/lib/et/et_c.awk
+++ b/lib/et/et_c.awk
@@ -237,19 +237,14 @@ END {
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
@@ -258,8 +253,12 @@ END {
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
diff --git a/lib/et/test_cases/continuation.c b/lib/et/test_cases/continuation.c
index d48f1fd1..0529dd08 100644
--- a/lib/et/test_cases/continuation.c
+++ b/lib/et/test_cases/continuation.c
@@ -25,19 +25,14 @@ const struct error_table et_ovk_error_table = { text, 43787520L, 1 };
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;
@@ -46,8 +41,12 @@ void initialize_ovk_error_table_r(struct et_list **list)
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;
diff --git a/lib/et/test_cases/heimdal.c b/lib/et/test_cases/heimdal.c
index 3ae62e36..22c75738 100644
--- a/lib/et/test_cases/heimdal.c
+++ b/lib/et/test_cases/heimdal.c
@@ -106,19 +106,14 @@ const struct error_table et_krb_error_table = { text, 39525376L, 82 };
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;
@@ -127,8 +122,12 @@ void initialize_krb_error_table_r(struct et_list **list)
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;
diff --git a/lib/et/test_cases/heimdal2.c b/lib/et/test_cases/heimdal2.c
index 261c8521..eba3d62e 100644
--- a/lib/et/test_cases/heimdal2.c
+++ b/lib/et/test_cases/heimdal2.c
@@ -92,19 +92,14 @@ const struct error_table et_kadm_error_table = { text, -1783126272L, 68 };
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;
@@ -113,8 +108,12 @@ void initialize_kadm_error_table_r(struct et_list **list)
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;
diff --git a/lib/et/test_cases/heimdal3.c b/lib/et/test_cases/heimdal3.c
index 4c475a2b..18a9ccc6 100644
--- a/lib/et/test_cases/heimdal3.c
+++ b/lib/et/test_cases/heimdal3.c
@@ -26,19 +26,14 @@ const struct error_table et_h3test_error_table = { text, 43787520L, 2 };
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;
@@ -47,8 +42,12 @@ void initialize_h3test_error_table_r(struct et_list **list)
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;
diff --git a/lib/et/test_cases/imap_err.c b/lib/et/test_cases/imap_err.c
index f41227b2..82a6ad06 100644
--- a/lib/et/test_cases/imap_err.c
+++ b/lib/et/test_cases/imap_err.c
@@ -54,19 +54,14 @@ const struct error_table et_imap_error_table = { text, -1904809472L, 30 };
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;
@@ -75,8 +70,12 @@ void initialize_imap_error_table_r(struct et_list **list)
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;
diff --git a/lib/et/test_cases/simple.c b/lib/et/test_cases/simple.c
index 94db6a12..f182c6f9 100644
--- a/lib/et/test_cases/simple.c
+++ b/lib/et/test_cases/simple.c
@@ -46,19 +46,14 @@ const struct error_table et_krb_error_table = { text, 39525376L, 22 };
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;
@@ -67,8 +62,12 @@ void initialize_krb_error_table_r(struct et_list **list)
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;