ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
One of the header prototypes is probably not coded exactly the way the compiler wants it. I think there is a "no deference" switch for gcc and g++ that you could try. I'm not able to locate the exact code, because I need more context from the compiler, and preferably some debug traces.
I have a hunch uint16 type is a culprit. Try using that header from the kernel headers instead of the libc6 one.
so your server program is server (instead or serverchat), your client program is client (instead of clientchat).
The name of the created program is the string after the -o option. see the man page of gcc...
Write output to file. This is the same as specifying file as the second non-option argument to cpp. gcc has a different interpretation of a second non-option argument, so you must use -o to specify the output file
Please be advised that your posted code sample contains a likely heap-based buffer overflow which an attacker might be able to leverage to exploit the system. Use of strcpy() should be limited to instances where the source buffer is not user-controlled or has already been bounds checked. strncpy(buf, argv, 120) would prevent this type of attack in the event that argv does not null terminate within 120 bytes.
For more information on how this could compromise your system, please check out my blog regarding stack-based buffer overflows which are even more dangerous. (Heap based overflows can certainly still lead to code execution and crashes.)