fix NULL in middle of spawn and typecast

This commit is contained in:
Michael Wehr
2022-02-14 21:07:00 +01:00
parent 7fe882ec46
commit dfb9623dcb

View File

@@ -1,6 +1,6 @@
diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
--- coreutils-9.0/src/copy.c 2021-09-24 13:31:05.000000000 +0200 --- coreutils-9.0/src/copy.c 2021-09-24 13:31:05.000000000 +0200
+++ coreutils-9.0-patched/src/copy.c 2022-02-13 16:09:25.450003849 +0100 +++ coreutils-9.0-patched/src/copy.c 2022-02-14 21:04:58.552402945 +0100
@@ -129,6 +129,133 @@ @@ -129,6 +129,133 @@
dev_t dev; dev_t dev;
}; };
@@ -464,7 +464,7 @@ diff -aur coreutils-9.0/src/copy.c coreutils-9.0-patched/src/copy.c
if (x->preserve_timestamps) if (x->preserve_timestamps)
diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h
--- coreutils-9.0/src/copy.h 2021-09-24 13:31:05.000000000 +0200 --- coreutils-9.0/src/copy.h 2021-09-24 13:31:05.000000000 +0200
+++ coreutils-9.0-patched/src/copy.h 2022-02-13 16:09:25.454003885 +0100 +++ coreutils-9.0-patched/src/copy.h 2022-02-14 21:04:58.564403350 +0100
@@ -236,6 +236,11 @@ @@ -236,6 +236,11 @@
Create destination directories as usual. */ Create destination directories as usual. */
bool symbolic_link; bool symbolic_link;
@@ -502,7 +502,7 @@ diff -aur coreutils-9.0/src/copy.h coreutils-9.0-patched/src/copy.h
#endif #endif
diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
--- coreutils-9.0/src/cp.c 2021-09-24 13:31:05.000000000 +0200 --- coreutils-9.0/src/cp.c 2021-09-24 13:31:05.000000000 +0200
+++ coreutils-9.0-patched/src/cp.c 2022-02-13 16:09:25.454003885 +0100 +++ coreutils-9.0-patched/src/cp.c 2022-02-14 21:04:58.572403620 +0100
@@ -131,6 +131,9 @@ @@ -131,6 +131,9 @@
{"symbolic-link", no_argument, NULL, 's'}, {"symbolic-link", no_argument, NULL, 's'},
{"target-directory", required_argument, NULL, 't'}, {"target-directory", required_argument, NULL, 't'},
@@ -564,7 +564,7 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
+ FILE *fp ; + FILE *fp ;
+ char output[1024]; + char output[1024];
+ char fcmd[] = "find"; + char fcmd[] = "find";
+ fp = spawn(fcmd, (char *[]){ fcmd, file[0], NULL, "-type", "f", NULL }); + fp = spawn(fcmd, (char *[]){ fcmd, file[0], "-type", "f", NULL });
+ if ( fp == NULL) + if ( fp == NULL)
+ printf("failed to run find\r"); + printf("failed to run find\r");
+ else + else
@@ -718,7 +718,7 @@ diff -aur coreutils-9.0/src/cp.c coreutils-9.0-patched/src/cp.c
version_control_string) version_control_string)
diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c
--- coreutils-9.0/src/mv.c 2021-09-24 13:31:05.000000000 +0200 --- coreutils-9.0/src/mv.c 2021-09-24 13:31:05.000000000 +0200
+++ coreutils-9.0-patched/src/mv.c 2022-02-13 16:09:25.458003920 +0100 +++ coreutils-9.0-patched/src/mv.c 2022-02-14 21:04:58.580403890 +0100
@@ -66,6 +66,9 @@ @@ -66,6 +66,9 @@
{"target-directory", required_argument, NULL, 't'}, {"target-directory", required_argument, NULL, 't'},
{"update", no_argument, NULL, 'u'}, {"update", no_argument, NULL, 'u'},
@@ -759,7 +759,7 @@ diff -aur coreutils-9.0/src/mv.c coreutils-9.0-patched/src/mv.c
+ FILE *fp ; + FILE *fp ;
+ char output[1024]; + char output[1024];
+ char fcmd[] = "find"; + char fcmd[] = "find";
+ fp = spawn(fcmd, (char *[]){ fcmd, (unsigned char *)(size_t)source, NULL, "-type", "f", NULL }); + fp = spawn(fcmd, (char *[]){ fcmd, (char *)source, "-type", "f", NULL });
+ if ( fp == NULL) + if ( fp == NULL)
+ printf("failed to run find\r"); + printf("failed to run find\r");
+ else + else