C ++ causing VIRUS errors?

You may call me crazy after reading this post, but I really ask you to trust me when you read what I say here. In an attempt to understand situations in which a memory leak or other errors may occur, I wrote the following code and tried compiling on my computer,

#include <iostream> using namespace std; class game { int x; public : char *s; char read(); char manipulation(); }; char game :: read() { char string[100]; cout<<"Enter name "; cin>>string; s = string; cout<<"Name is "<<&s<<endl; } int main() { game games,games1; // games.read(); cout<<"Name is "<<games.s<<endl; return 0; } 

If I execute games.read () in my main article, my BITDEFENDER antivirus software shows me the following error: "BITDEFENDER detected an infected element in c: / C ++ / inline.exe. Virus name: Gen: Variant.Graftor.51542. File was cured for your protection. "

inline.cpp is the name of my program. If I delete this line "games.read ()", it compiles in order. Is a pointer causing a memory leak somewhere?

+4
source share
2 answers

Your antivirus program has just discovered a vulnerability after use.

string is a local array.
You cannot use it after read() exits.

+13
source

If your system claims that your code is a virus, then you have nothing to worry about in the sense that you are losing your mind; You do not.

Virus scanners will look for and report virus-compatible behavior patterns. They are not perfect, and non-virus behavior can sometimes look like a virus.

For example, the classic antivirus strategy is to use invalid pointer entries to run arbitrary code. One of the first viruses used this, and it is still a common strategy (I recently recalled an IE update to fix this). Therefore, if you have a pointer error (as the previous poster noted), it may look like a virus.

+2
source

All Articles