forked from junamai2000/mysql_unserialize_php
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.cc
38 lines (29 loc) · 859 Bytes
/
test.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include "pfc.h"
int main(int argc, char *argv[])
{
if (!pfc_initialize()) {
return -1;
}
if (!pfc_evalf(__func__, "echo \"My name is %s\n\";", argv[0])) {
return -1;
}
//pfc_set_string("name", argv[0], sizeof("name"));
// O:8:"stdClass":2:{s:1:"a";s:4:"aaaa";s:1:"b";s:4:"bbbb";}
pfc_set_string("unserializable_string", argv[1], sizeof("unserializable_string"));
if (!pfc_eval(__func__, "$obj=unserialize($unserializable_string);")) {
pfc_finalize();
return -1;
}
if (!pfc_evalf(__func__, "$output=%s;","$obj->b")) {
return -1;
}
std::string *value=new std::string;
if (!pfc_get_string("output", value, sizeof("output"))) {
return -1;
}
printf("%s\n", value->c_str());
delete value;
pfc_finalize();
return 0;
}