Skip to content

Statically allocated arrray "hex_output" in md5_hash #1

Description

@arhimondr

I don't know which thread model Varnish 3 use, however Varnish 4 create simultaneous thread for each request. Regarding this, when use md5_hash inside vcl_recv then race condition will happen inside md5_hash and incorrect MD5 will be returned.

In my code i solve this issue creating

char* hex_output = malloc(16*2 + 1); 

and in vcl file

char* md5DigestString = VRT_GetHdr(ctx, &VGC_HDR_REQ_VARNISH_X_DIGEST);
const char* calculatedMD5 = (*md5_hash)(md5DigestString);
VRT_SetHdr(ctx, &VGC_HDR_REQ_VARNISH_X_MD5, calculatedMD5, vrt_magic_string_end);
free((void*)calculatedMD5);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions