The gnu extension to have realpath() malloc its buffer when handed a NULL
authorRob Landley <rob@landley.net>
Wed, 17 May 2006 04:09:14 +0000 (04:09 -0000)
committerRob Landley <rob@landley.net>
Wed, 17 May 2006 04:09:14 +0000 (04:09 -0000)
isn't implemented in uClibc, so we can't use it.

debianutils/readlink.c

index 83abdbfa6049fde18e6701783e2a4c854e9265f6..79f0870ec034bf110a3764b047eae9ccb7d248fa 100644 (file)
@@ -25,7 +25,7 @@ int readlink_main(int argc, char **argv)
                        bb_show_usage();
 
        if (opt & READLINK_FLAG_f)
-               buf = realpath(argv[optind], NULL);
+               buf = realpath(argv[optind], bb_common_bufsiz1);
        else
                buf = xreadlink(argv[ENABLE_FEATURE_READLINK_FOLLOW ? optind : 1]);
 
@@ -33,7 +33,7 @@ int readlink_main(int argc, char **argv)
                return EXIT_FAILURE;
        puts(buf);
 
-       if (ENABLE_FEATURE_CLEAN_UP) free(buf);
+       if (ENABLE_FEATURE_CLEAN_UP && buf != bb_common_bufsiz1) free(buf);
 
        return EXIT_SUCCESS;
 }