c2rust icon indicating copy to clipboard operation
c2rust copied to clipboard

analyze: tracking issue for lighttpd algo_md5

Open spernsteiner opened this issue 2 years ago • 1 comments

We'd like to be able to fully refactor lighttpd's algo_md5 module into safe Rust. This tracking issue covers analysis features that will be required to support that:

  • [x] Casts from Single to non-Single Quantity. This may be a bug, possibly with our handling of array.as_mut_ptr(); if the cast's output has PermissionSet::OFFSET (causing it to have non-Single Quantity), then the input should have that permission as well.
    • [ ] Investigate to determine why the analysis wants to insert this cast
  • [ ] void* arguments for local functions. Specifically, MD5_Update takes a pointer to bytes as the argument void* _input.
    • [ ] Track concrete pointee types through void* and char* casts
    • [ ] Rewrite argument types from *mut c_void to a more specific safe type
  • [ ] Rewrite memcpy into copy_from_slice.
  • [ ] Rewrite memset(&s, 0, sizeof(s)) into zero-initialization of each field of s.
  • [x] Fix unsupported cast kind: TypeDesc
    • [ ] Investigate further - which TypeDescs is it failing on?
  • [x] Fix unlower_map has no origin - possibly fixed by #1020
  • [x] Figure out why the context pointer is getting OFFSET permission in several functions
  • [ ] Fix bad cast in MD5_Update's call to li_MD5Transform:
    // old:
    ((*context).buffer).as_mut_ptr() as *const libc::c_uchar
    // new:
    &*(&mut (((*context).buffer)) as &mut [u8]) as *const libc::c_uchar
    
    The final ... as *const libc::c_uchar should be removed.

spernsteiner avatar Sep 11 '23 22:09 spernsteiner

Just merged #1022 which lets algo_md5 pass without modifications.

oinoom avatar Sep 18 '23 23:09 oinoom