Multidimensional array and dllhijacking
I'am currently working on a tool which checks if your apps are vulnerable to dllhijacking. Anyway, there's a section in my code which doesn't look very elegant. Now there are just two sets, but I want to add some more. Is there another way instead of just adding for loops for each set?
LPSTR szFileExtWireShark[] = {"airpcap.dll", ".bfr", ".enc", ".fdc", ".pcap", ".pcapng", ".syc", NULL};
LPSTR szFileExtWin7[] = {"wab32res.dll", ".contact", ".group", ".p7c", ".vcf", NULL};
int loadSets(LPSTR szFileName, LPSTR szPath) {
int counter;
for(counter=1; szFileExtWireShark[counter] != NULL; counter++) {
checkExt(szFileName, szPath, szFileExtWireShark[counter], szFileExtWireShark[0]);
}
for(counter=1; szFileExtWin7[counter] != NULL; counter++) {
checkExt(szFileName, szPath, szFileExtWin7[counter],开发者_Go百科 szFileExtWin7[0]);
}
}
using single loop
LPSTR szFileExtWireShark[] = {"airpcap.dll", ".bfr", ".enc", ".fdc", ".pcap", ".pcapng", ".syc", NULL};
LPSTR szFileExtWin7[] = {"wab32res.dll", ".contact", ".group", ".p7c", ".vcf", NULL};
int loadSets(LPSTR szFileName, LPSTR szPath) {
int counter;
for(counter=1; (szFileExtWireShark[counter] != NULL && szFileExtWin7[counter] != NULL); counter++) {
if(szFileExtWireShark[counter] != NULL)
checkExt(szFileName, szPath, szFileExtWireShark[counter], szFileExtWireShark[0]);
if(szFileExtWin7[counter] != NULL)
checkExt(szFileName, szPath, szFileExtWin7[counter], szFileExtWin7[0]);
}
}
精彩评论