]> The Tcpdump Group git mirrors - tcpdump/commitdiff
ESP: Add a workaround to a "use-of-uninitialized-value"
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 12 Aug 2022 14:43:41 +0000 (16:43 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 12 Aug 2022 14:54:37 +0000 (16:54 +0200)
Found with clang, CFLAGS=-fsanitize=memory.

Fix GitHub issues #848 and #849.

The problem is that for some unknown reason the pt buffer is not
initialized after EVP_DecryptUpdate() call, no error, in:

print-esp.c:260:        if (!EVP_DecryptUpdate(ctx, pt, &len, ct, ctlen)) {

print-esp.c

index fb94a60a5c438536e3f718704ed47919f7dcd7be..0ddcca79c85c83a6aad05d1d9432e544a45db298 100644 (file)
@@ -238,7 +238,7 @@ do_decrypt(netdissect_options *ndo, const char *caller, struct sa_list *sa,
         * we can't decrypt on top of the input buffer.
         */
        ptlen = ctlen;
-       pt = (u_char *)malloc(ptlen);
+       pt = (u_char *)calloc(1, ptlen);
        if (pt == NULL) {
                EVP_CIPHER_CTX_free(ctx);
                (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC,