libblkid-tiny: fix symbol collision with full libblkid
authorJo-Philipp Wich <jo@mein.io>
Sun, 22 Dec 2019 18:46:05 +0000 (19:46 +0100)
committerJo-Philipp Wich <jo@mein.io>
Sun, 22 Dec 2019 18:54:42 +0000 (19:54 +0100)
The recent introduction of blkid_new_probe() and blkid_free_probe() in the
dynamically linked libblkid-tiny caused the dlopen'd libblkid.so to call into
the wrong version of blkid_new_probe() within blkid_new_probe_from_filename(),
leading to memory corruption and eventual segmentation faults.

Fixes: b82c5c1 ("libblkid-tiny: add functions for allocating & freeing probe struct")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libblkid-tiny/blkid.h
libblkid-tiny/libblkid-tiny.h
libblkid-tiny/probe.c
probe.c

index 799e699161421e25ba4a5bb46c8b49d4d0452858..be16b8fb84c2893862ba9269be18c848ce2d647a 100644 (file)
@@ -215,11 +215,11 @@ extern char *blkid_evaluate_spec(const char *spec, blkid_cache *cache)
                        __ul_attribute__((warn_unused_result));
 
 /* probe.c */
-extern blkid_probe blkid_new_probe(void)
+extern blkid_probe blkidtiny_new_probe(void)
                        __ul_attribute__((warn_unused_result));
 extern blkid_probe blkid_new_probe_from_filename(const char *filename)
                        __ul_attribute__((warn_unused_result));
-extern void blkid_free_probe(blkid_probe pr);
+extern void blkidtiny_free_probe(blkid_probe pr);
 
 extern void blkid_reset_probe(blkid_probe pr);
 
index aa87fd9a225a1ec363346658d995def4d9342351..f0922b5f7aeb3c8a24fd3cd4771774a0068de96e 100644 (file)
@@ -62,8 +62,8 @@ struct blkid_struct_probe
        struct list_head        buffers;        /* list of buffers */
 };
 
-struct blkid_struct_probe *blkid_new_probe(void);
-void blkid_free_probe(struct blkid_struct_probe *pr);
+struct blkid_struct_probe *blkidtiny_new_probe(void);
+void blkidtiny_free_probe(struct blkid_struct_probe *pr);
 
 extern int probe_block(char *block, struct blkid_struct_probe *pr);
 extern int mkblkdev(void);
index ae7e7088f36d39556ce8411b5e5d09f2e053be63..bf68840bd56a651ec7ed0bce24932cc6e61b10ed 100644 (file)
@@ -14,7 +14,7 @@
 
 static int blkid_probe_reset_buffers(struct blkid_struct_probe *pr);
 
-struct blkid_struct_probe *blkid_new_probe(void)
+struct blkid_struct_probe *blkidtiny_new_probe(void)
 {
        struct blkid_struct_probe *pr;
 
@@ -27,7 +27,7 @@ struct blkid_struct_probe *blkid_new_probe(void)
        return pr;
 }
 
-void blkid_free_probe(struct blkid_struct_probe *pr)
+void blkidtiny_free_probe(struct blkid_struct_probe *pr)
 {
        if (!pr)
                return;
diff --git a/probe.c b/probe.c
index 7d0e83133cf3e78ebd3ec0a5df904140d9768a16..3ed7a7dafd673718ced927216ec9ebdf8f14b53e 100644 (file)
--- a/probe.c
+++ b/probe.c
@@ -24,7 +24,7 @@ probe_path_tiny(const char *path)
        struct blkid_struct_probe *pr;
        char *type, *dev, *uuid, *label, *version;
 
-       pr = blkid_new_probe();
+       pr = blkidtiny_new_probe();
        if (!pr)
                return NULL;
 
@@ -53,7 +53,7 @@ probe_path_tiny(const char *path)
                }
        }
 
-       blkid_free_probe(pr);
+       blkidtiny_free_probe(pr);
 
        return info;
 }