Search code examples
cwindowstrojanwindows-defender

WindowsDefender Trojan warning after compiling c program with string.h and stdio.h?


As you will see I am not good in c programming, still learning but my WindowsDefender is yelling at me for compiling this code with MinGW from Codeblocks IDE.

#include <stdio.h>
#include <string.h>

int main(void){

char *strings[] = {"test", "test"};
char *newStr;
int i;
for(i=0;i<2;i++){
   strcat(newStr, strings[i]);
   printf("%s\n", newStr);
}

return 0;
}

This is the Warning from Windows Defender

Can you help me with that I don't know what this is about. This can't be a normal issue mh?


Solution

  • I have been having this for several days recently when I compile simple programs in C in Microsoft Visual Studio 2019 Community edition. For example this one.

    #include <stdio.h>
    
    int main() {
    
        int a = 10;
        for (int i = 0; i < 5; i++) {
            a--;
            printf("i = %d\n", i);
            if (a == 8) break;
        }
    }
    

    The problem isn't with your program (or mine) but Windows Defender has become overly paranoid and is erroneously identifying normal compiled code. I get the same Trojan warning as you. The danger is if we turn off Defender for crying wolf that a real virus could slip onto an unguarded Pc. I'm tempted to switch to a different a/v like AVG or switch into hyper-V and compile programs on Ubuntu with GCC or clang.