Skip to content

Tag: c++

Understanding the strcmp function of gnu libc

Here is the strcmp function that i found in the glibc: This is a pretty simple function where the body of while initiates c1 and c2 with the value of *s1 and *s2 and continues till either c1 is nul or the values of c1 and c2 are equal, then returns the difference between c1 and c2. What i didn’t

Finding mapped memory from inside a process

Setup: Ubuntu 18×64 x86_64 application Arbitrary code execution from inside the application I’m trying to write code which should be able to find structures in memory even with ASLR enabled. Sadly, I couldn’t find any static references to those regions, so I’m guessing I have to use the…

Understanding read syscall

I’m reading man read manual page and discovered that it was possible to read less then the desired number of bytes passed in as a parameter: It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now (…

Timing/Clocks in the Linux Kernel

I am writing a device driver and want to benchmark a few pieces of code to get a feel for where I could be experiencing some bottlenecks. As a result, I want to time a few segments of code. In userspace, I’m used to using clock_gettime() with CLOCK_MONOTONIC. Looking at the kernel sources (note that I a…

C – in recursive function remove() dont work

obviating if the recursive function is well constructed or not, when i call the function on a directory Folder/file.txt. this code should delete file.txt, but when it reaches to remove dont work, and i dont know for what… Answer Reading the man page on readdir, it returns in d_name a file name, not a co…