Sunday, December 2, 2012

What is buffer overflow in unmanaged code?

Buffer overflow is a condition wherein a memory space is filled with more content than the memory space can consume. This will result in adjacent memory space being overwritten and will have potentially serious security vulnerabilities. Buffer overflows are usually the cause of major security vulnerabilities in recent times and have resulted in billions of dollars of loses to the world economy. A simple example-> let's say we have an char array with 100 size -> char[] myMemory. If we do memcpy(myMemory, "huge content …..", 1000) ie., filling the memory with 1000 chars than 100 then there is a buffer overflow.

What is difference between thread and a process?

A process can have multiple threads. OS's scheduler gives CPU time to each thread. Each thread has its own stack but all threads share the same process heap. A process can technically control the thread life cycle -> creating, aborting, joining etc.

What are semaphores?

What are dead locks?