Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,570 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,663 people online right now. Registration is fast and FREE... Join Now!




vulnerable code?

 
Reply to this topicStart new topic

vulnerable code?

Apples
28 Oct, 2007 - 07:16 PM
Post #1

New D.I.C Head
*

Joined: 15 Nov, 2006
Posts: 21


My Contributions
i wrote a simple copy program, and checked it over, but found no vulnerabilities. before using this in an application i'm working on, i was hoping that someone else could take a look and make sure nothing i've done is insecure. thanks! smile.gif

CODE

#include <stdio.h>

int main(int argc, char *argv[])
{
    if(argc != 3)
    {
        printf("usage: %s [source] [dest]\n", argv[0]);
        exit(1);
    }

    char x;
    FILE *file[2];
    file[0] = fopen(argv[1],"r+");
    file[1] = fopen(argv[2],"w+");

    for(x = 0; x < 2; x++)
    {
        if(file[x] == NULL)
        {
            printf("error opening file.\n");
            exit(1);
        }
    }

    do
    {
        x = fgetc(file[0]);
        fputc(x,file[1]);
    }
    while(x != EOF);

    for(x = 0; x < 2; x++)
        fclose(file[x]);

    return 0;
}

User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Vulnerable Code?
28 Oct, 2007 - 07:37 PM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,868



Thanked: 53 times
Dream Kudos: 550
My Contributions
What do you mean by "vulnerable" and "insecure"?


User is online!Profile CardPM
+Quote Post

Apples
RE: Vulnerable Code?
29 Oct, 2007 - 07:50 AM
Post #3

New D.I.C Head
*

Joined: 15 Nov, 2006
Posts: 21


My Contributions
something like a buffer overflow that allows arbitrary execution of code.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/7/09 10:20PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month