Closed migraine-sudo closed 3 years ago
This is known limitation of that library. We have a newer version in semmle.code.cpp.ir.dataflow.TaintTracking
that has improved handling of both fields and these kinds of side effects. Could you try importing that version instead (the API is the same) and see if that fixes your issue?
This is known limitation of that library. We have a newer version in
semmle.code.cpp.ir.dataflow.TaintTracking
that has improved handling of both fields and these kinds of side effects. Could you try importing that version instead (the API is the same) and see if that fixes your issue?
Thank you, according to the method you provided, taint tracking has already supported the structure. Wish you the best at work!
namespace ara {
namespace diag {
class ProcessMessage {
public:
struct msg {
int msg_size;
char *msg;
};
virtual void handle_msg(char *msg) = 0;
virtual void handle_struct(struct msg *the_msg) = 0;
};
int do_handle_msg(char *msg) {
char buff[128] = "helloworld";
int fd = open(msg, O_RDWR | O_CREAT, 777);
if (fd == -1) {
std::cout << "file error" << std::endl;
}
int ret = write(fd, buff, strlen(buff));
if (ret < 0) {
std::cout << "write fail" << std::endl;
}
for (int i = 0; i < atoi(msg); i++) {
printf("helloworld");
}
for (int j = atoi(msg); j < 10; j++) {
printf("helloworld");
}
int k = 0;
for (k = atoi(msg); k < 10; k++) {
printf("helloworld\n");
}
while (k++ < atoi(msg)) { ;
}
int l = atoi(msg);
while (l++ < 10) { ; }
do {
} while (l++ < 10);
do { ;
} while (k++ < atoi(msg));
std::vector<std::string> vect = {"1", "2", "34"};
for (std::string str : vect) {
printf("%s\n", str.c_str());
}
char myarr[1024];
printf("%c", myarr[atoi(msg)]);
close(fd);
return 0;
}
int do_handle_struct_msg(struct ProcessMessage::msg *the_msg) {
//for in localVar
for (int i = 0; i < the_msg->msg_size; i++);
int i, j, k;
//while
while (i++ < the_msg->msg_size);
//do while
do { ;
} while (j++ < the_msg->msg_size);
//for in assignExpr
for (i = the_msg->msg_size; i < 10; i++);
//for in initial
for (int i = the_msg->msg_size; i < 10; i++);
k = the_msg->msg_size;
//while in loopcount
while (k++ < 10);
//do while in loopcount
do { ;
} while (k++ < 100);
return 1;
}
class ProcessMessageImp : public ProcessMessage {
public:
void handle_msg(char *msg) {
do_handle_msg(msg);
}
void handle_struct(struct ProcessMessage::msg *the_msg) override {
do_handle_struct_msg(the_msg);
}
};
}
}
I have the same question, how can I taint track from handle_struct‘s first parameter to the loop condition
Hello, I tried to use CodeQL's global taint tracking. I have tested variables/functions/pointers and have good results. But when I tried to trace the C language structure, I found that taint tracking failed. I am very puzzled. Below is my Demo and QL
This is the rule I wrote (I simplified some so that you can grasp the key points). I want to track the pollution caused by the get_user_input function to the struct message operation.
Thanks, if there are some problems, I will also provide help as much as I can