← Commit list

b0e8ced35

Denys Vlasenko
Denys Vlasenko
2011-03-21
FAILED Duration: 252s

Subject

ln: explain why we use xstrdup

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/ln.c+5 -1
@@ -40,8 +40,12 @@ int ln_main(int argc, char **argv)
last = argv[argc - 1];
argv += optind;
- if (argc == optind + 1) {
+ if (!argv[1]) {
+ /* "ln PATH/TO/FILE" -> "ln PATH/TO/FILE FILE" */
*--argv = last;
+ /* xstrdup is needed: "ln -s PATH/TO/FILE/" is equivalent to
+ * "ln -s PATH/TO/FILE/ FILE", not "ln -s PATH/TO/FILE FILE"
+ */
last = bb_get_last_path_component_strip(xstrdup(last));
}