gpt4 book ai didi

CGI 程序在curl_easy_init() 上崩溃

转载 作者:行者123 更新时间:2023-11-30 17:39:38 26 4
gpt4 key购买 nike

我有一个通用文件 getter C 程序,在 shell 上运行时可以完美运行,但在转换为 CGI 脚本并运行相同的程序后,崩溃了

curl = curl_easy_init();

我再说一遍,这在 shell 模式下运行良好,我得到了我想要的文件,但在 CGI 中它只会使脚本崩溃。

编辑:这是脚本中断后的 Apache 日志。

malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.

好的,这些是我为从表单读取 POST 数据而进行的初始化。

len = atoi((char *) getenv("CONTENT_LENGTH"));
posted = malloc(len + 1);
decoded = malloc(len + 100); // Currently for pics only 10 * 10 pics
//fgets(data, length, stdin);
fread(posted, len, 1, stdin); // rawdata contains standard input coming from HTTP POST
printf("POST: %s\n", posted);

decode_post_keys_(posted, decoded, len+100); // Decode POST values
printf("DECODED: %s\n", decoded);
decode_value("id=", value, MAX_LEN);

当我阅读所选内容时,程序退出,这是一个 YouTube URL,我通过它运行一个获取 mp4 文件的程序。

printf("Video url: %s\n", row[0]);

/** Get the video ID from the string "v=" */
decode_value_post("v=", value, "http://www.youtube.com/watch?v=acq8BvIhUTg", /*row[0],*/ MAX_URL);
//strcpy(value, "acq8BvIhUTg");
printf("YouTube video id: %s\n", value);
muxer.youtube_url[0] = '\0';
strcpy(muxer.youtube_url, "http://www.youtube.com/get_video_info?video_id =");
strcat(muxer.youtube_url, value);

muxer.youtube_url[strlen(muxer.youtube_url)+1] = '\0';

muxer.vid_filesize = get_youtube_file(muxer.youtube_url, &muxer); // This is where it fails
printf("FILE-SIZE: %d\n", muxer.vid_filesize);

因此,函数 get_youtube_file 的curl_easy_init() 失败了。

最佳答案

好的,找到解决方案了。我还没有发布另一个实际解码发布数据的函数。显然该变量没有足够的空间来保存解码的数据。我已将其改进为额外 5000,并且有效。

size_t len = atol((char *) getenv("CONTENT_LENGTH"); // post data length
char *decoded = malloc(len + EXTRA);
decode_post_keys_(posted, decoded, len+EXTRA);

这有效。 :-)

关于CGI 程序在curl_easy_init() 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21747791/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com