[PATCH] px5g-mbedtls error check
Daniel Golle
daniel at makrotopia.org
Mon Dec 5 13:27:10 PST 2022
Hi Peter,
thank you for pointing this out and submitting a patch.
On Mon, Dec 05, 2022 at 02:03:48PM -0500, Peter Naulls wrote:
>
>
> In 22.03, px5-mbedtls isn't bothering to check if the output was opened:
You patch lacks a Signed-off-by: line in the end of the patch
description.
>
> --- a/package/utils/px5g-mbedtls/px5g-mbedtls.c
> +++ b/package/utils/px5g-mbedtls/px5g-mbedtls.c
> @@ -29,6 +29,7 @@
> #include <unistd.h>
> #include <fcntl.h>
> #include <stdbool.h>
> +#include <errno.h>
>
> #include <mbedtls/bignum.h>
> #include <mbedtls/x509_crt.h>
> @@ -70,6 +71,11 @@ static void write_file(const char *path, int len, bool pem)
> if (path)
> f = fopen(path, "w");
>
> + if (!f) {
> + fprintf(stderr, "Failed to open output '%s': %s\n", path,
> strerror(errno));
> + exit(1);
> + }
> +
> fwrite(buf_start, 1, len, f);
> fclose(f);
> }
Unfortunately your mail user agent has mangled the tabs into 4 spaces
which results in the patch no longer applying:
warning: Patch sent with format=flowed; space at the end of lines might be lost.
Applying: px5g-mbedtls error check
error: patch failed: package/utils/px5g-mbedtls/px5g-mbedtls.c:70
error: package/utils/px5g-mbedtls/px5g-mbedtls.c: patch does not apply
Patch failed at 0001 px5g-mbedtls error check
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
...
To avoid problems like that, please use 'git send-email' or at least
'git format-patch' to submit the patch. If using a specific graphical
or web mail user agent cannot be avoided at all, as a last resort it is
also ok to send patches generated using 'git format-patch' as an
attachment.
To be consistent in style it would also be better to change the patch
subject to "px5g-mbedtls: add error check" or something like that.
Cheers
Daniel
More information about the openwrt-devel
mailing list