Browse Source

libblkid-tiny: fix symbol collision with full libblkid

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>
Jo-Philipp Wich 4 years ago
parent
commit
b4e25d5403
4 changed files with 8 additions and 8 deletions
  1. 2 2
      libblkid-tiny/blkid.h
  2. 2 2
      libblkid-tiny/libblkid-tiny.h
  3. 2 2
      libblkid-tiny/probe.c
  4. 2 2
      probe.c

+ 2 - 2
libblkid-tiny/blkid.h

@@ -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);
 

+ 2 - 2
libblkid-tiny/libblkid-tiny.h

@@ -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);

+ 2 - 2
libblkid-tiny/probe.c

@@ -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;

+ 2 - 2
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;
 }