]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
et_c.awk: Use a dynamically allocated structure in
authorTheodore Ts'o <tytso@mit.edu>
Mon, 20 Jun 2005 20:24:04 +0000 (16:24 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 20 Jun 2005 20:24:04 +0000 (16:24 -0400)
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)

lib/et/ChangeLog
lib/et/et_c.awk
lib/et/test_cases/continuation.c
lib/et/test_cases/heimdal.c
lib/et/test_cases/heimdal2.c
lib/et/test_cases/heimdal3.c
lib/et/test_cases/imap_err.c
lib/et/test_cases/simple.c

index 4bfb0d338ffa3461e4b12a28613ebc7446ef008d..aa4880f8cdb2afa58ea2177ca944f0d900984090 100644 (file)
@@ -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
index 1769b79a3094e8183b88a970d716f6618c7baede..407c43cc0ce9caa8507760bc37ab4712a7b1790b 100644 (file)
@@ -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
index d48f1fd189af32485bae3df2eb117572bc11681c..0529dd084e31211587f1cc62e98995d5ca46a15f 100644 (file)
@@ -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;
index 3ae62e3633b7a5756e493d39f65f67cfeadc5c3a..22c75738c3e5d8f763c89bb53a8398686ea07b5c 100644 (file)
@@ -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;
index 261c852197917cf8186d12d9e4b48b9eb3cadedf..eba3d62e8be110ce7af9d5aaa5853328de8c2f43 100644 (file)
@@ -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;
index 4c475a2b9087a5766cf0fd8f6c54623730deb4e8..18a9ccc6eb681cad810dc0a9186b2e93c7d44f56 100644 (file)
@@ -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;
index f41227b2c10784344a5001fb5342da243a58776c..82a6ad0640f386bc0c46f700e317fc2c4bc5eba2 100644 (file)
@@ -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;
index 94db6a1261caf3e48590a5e4152f58ad4efcf2c8..f182c6f9f30494164a66dd789d12e48ef9a9baf0 100644 (file)
@@ -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;