https://bugs.kde.org/show_bug.cgi?id=504341

Mark Wielaard <m...@klomp.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |m...@klomp.org

--- Comment #2 from Mark Wielaard <m...@klomp.org> ---
Almost correct. But in this particular case there is a tricky logic issue where
the else clause should be taken only if the ARG is not NULL (not when it
contains an inaccessible argument). Things are a little complicated here
because we explicitly use SET_STATUS_Success( 0 ) and SET_STATUS_Failure(
VKI_EINVAL ) to pretend the syscall succeeded or failed but if we call those
macros we do things ourselves and don't actually call the syscall.

So I think the correct way is having this nested if statement instread of &&
all conditions together:

   if (ARG3) {
      if (ML_(safe_to_deref)( (void*)(Addr)ARG3, sizeof(struct vki_rlimit64) ))
{
         if (((struct vki_rlimit64 *)(Addr)ARG3)->rlim_cur
             > ((struct vki_rlimit64 *)(Addr)ARG3)->rlim_max) {
            SET_STATUS_Failure( VKI_EINVAL );
         }
      }
   } else if (ARG1 == 0 || ARG1 == VG_(getpid)()) {

You should be able to test with the same setrlimit05 LTP testcase if he logic
is correct.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to