Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about JSON in proftpd crashes #271

Open
shunshunbu opened this issue Apr 16, 2024 · 1 comment
Open

question about JSON in proftpd crashes #271

shunshunbu opened this issue Apr 16, 2024 · 1 comment
Assignees
Labels

Comments

@shunshunbu
Copy link

shunshunbu commented Apr 16, 2024

This is a json test function. The function can be used normally. However, when the code runs to the following free functions, the program will exit abnormally. Could you please help me see where the problem is?

{
“task_type”:1,
"task_id":2,
"task_name":"test",
"templatecode":
[
 1001,
]
"filelist":
[
{
"file_dir":1,
"file_name":"testname",
"file_path":"testpath",
},
]
}
pool *tmp pool object;
tmp pool object = make sub pool(permanent pool),
pr_pool tag(tmp pool object,"json object pool"),

pr json object t *json object main;
json object main = pr json object alloc(tmp pool object);
pr_json object_set_number(tmp_pool object,json object main,"task type",1),
pr json object set number(tmp pool object,json object main,"task id",security check task id),
pr json object set string(tmp pool object,json object main,"task name","test");

pr json array t *json array templatecode;
json array templatecode = pr json array alloc(tmp pool object);
pr_json array append number(tmp pool object,json array templatecode,security check template id),
pr json object set array(tmp pool object, json object main, "template code",json array templatecode);

pr json object t *json object filelist;
json object filelist = pr json object alloc(tmp pool object),

pr json array t *json array filelist;
json array filelist = pr json array alloc(tmp pool object);

pr json object set number(tmp pool object,json object filelist,"file dir",2);
pr json object set string(tmp pool object,json object filelist,"file name",filename),
pr json object set string(tmp pool object,json object filelist,"file path",absolute path);

pr json array append object(tmp pool object,json array filelist,json object filelist),
pr json object set array(tmp pool object, json object main, "file list",json array filelist),

char *payload = NULL;
size t payload len = 0:
payload = pr json object to text(tmp pool object, json object main,"");
payload len =strlen(payload);

pr json array free(json array filelist):
pr json object free(json object filelist);
pr json array free(json array templatecode),
pr json object free(json object main);
destroy pool(tmp pool object);
@Castaglia
Copy link
Owner

If you are running this C program in a standalone fashion, you may need to initialize permanent_pool. It sounds like some of the pointers may be NULL, and your code is not checking for such conditions.

Without more specific details, I cannot offer better suggestions than to add error and bounds checking to your code.

@Castaglia Castaglia self-assigned this Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants