MCPcopy Create free account
hub / github.com/containers/bubblewrap / readlink_malloc

Function readlink_malloc

utils.c:841–862  ·  view source on GitHub ↗

Sets errno on error (== NULL), * Always ensures terminating zero */

Source from the content-addressed store, hash-verified

839/* Sets errno on error (== NULL),
840 * Always ensures terminating zero */
841char *
842readlink_malloc (const char *pathname)
843{
844 size_t size = 50;
845 ssize_t n;
846 cleanup_free char *value = NULL;
847
848 do
849 {
850 if (size > SIZE_MAX / 2)
851 die ("Symbolic link target pathname too long");
852 size *= 2;
853 value = xrealloc (value, size);
854 n = readlink (pathname, value, size - 1);
855 if (n < 0)
856 return NULL;
857 }
858 while (size - 2 < (size_t)n);
859
860 value[n] = 0;
861 return steal_pointer (&value);
862}
863
864char *
865get_oldroot_path (const char *path)

Callers 2

setup_newrootFunction · 0.85
bind_mountFunction · 0.85

Calls 3

dieFunction · 0.85
xreallocFunction · 0.85
steal_pointerFunction · 0.85

Tested by

no test coverage detected