toshic / libfcgi Goto Github PK
View Code? Open in Web Editor NEWlibfcgi patched by Yandex
License: Other
libfcgi patched by Yandex
License: Other
Hello,
(i am assigned to check every single component of our project.)
using:
cppcheck -q --force --enable=warning --inconclusive -v .
cppcheck is reporting:
[fastcgi-2.4/cgi-fcgi/cgi-fcgi.c:628]: (error) Resource leak: fp
Issue:
Returning from ParseArgs() without fclose(fp);
Using the fcgiapp, OS_LibShutdown is never called, causing unfreed memory. As OS_LibInit is called in FCGX_Accept(), I guess OS_LibShutdown should be called in FCGX_Finish().
I run `./configure' and everything is okay.
but during make, it show up errors and warnings.
system: Ubuntu 12.04 64bit
gcc: 4.8.4
[three@ubuntu(2): libfcgi-master]$ make
make all-recursive
make[1]: Entering directory `/home/three/WorkSpace/nginx/libfcgi-master'
Making all in libfcgi
make[2]: Entering directory `/home/three/WorkSpace/nginx/libfcgi-master/libfcgi'
/bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -g -O2 -Wall -MT libfcgi_la-fcgiapp.lo -MD -MP -MF .deps/libfcgi_la-fcgiapp.Tpo -c -o libfcgi_la-fcgiapp.lo `test -f 'fcgiapp.c' || echo './'`fcgiapp.c
mkdir .libs
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -g -O2 -Wall -MT libfcgi_la-fcgiapp.lo -MD -MP -MF .deps/libfcgi_la-fcgiapp.Tpo -c fcgiapp.c -fPIC -DPIC -o .libs/libfcgi_la-fcgiapp.o
fcgiapp.c: In function 'ProcessManagementRecord':
fcgiapp.c:1490:13: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
= MakeHeader(FCGI_GET_VALUES_RESULT, FCGI_NULL_REQUEST_ID,
^
fcgiapp.c:1495:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
((FCGI_UnknownTypeRecord *) response)->header
^
fcgiapp.c:1498:9: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
((FCGI_UnknownTypeRecord *) response)->body
^
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -g -O2 -Wall -MT libfcgi_la-fcgiapp.lo -MD -MP -MF .deps/libfcgi_la-fcgiapp.Tpo -c fcgiapp.c -o libfcgi_la-fcgiapp.o >/dev/null 2>&1
mv -f .deps/libfcgi_la-fcgiapp.Tpo .deps/libfcgi_la-fcgiapp.Plo
/bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -g -O2 -Wall -MT libfcgi_la-fcgi_stdio.lo -MD -MP -MF .deps/libfcgi_la-fcgi_stdio.Tpo -c -o libfcgi_la-fcgi_stdio.lo `test -f 'fcgi_stdio.c' || echo './'`fcgi_stdio.c
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -g -O2 -Wall -MT libfcgi_la-fcgi_stdio.lo -MD -MP -MF .deps/libfcgi_la-fcgi_stdio.Tpo -c fcgi_stdio.c -fPIC -DPIC -o .libs/libfcgi_la-fcgi_stdio.o
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -g -O2 -Wall -MT libfcgi_la-fcgi_stdio.lo -MD -MP -MF .deps/libfcgi_la-fcgi_stdio.Tpo -c fcgi_stdio.c -o libfcgi_la-fcgi_stdio.o >/dev/null 2>&1
mv -f .deps/libfcgi_la-fcgi_stdio.Tpo .deps/libfcgi_la-fcgi_stdio.Plo
/bin/bash ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -g -O2 -Wall -MT libfcgi_la-os_unix.lo -MD -MP -MF .deps/libfcgi_la-os_unix.Tpo -c -o libfcgi_la-os_unix.lo `test -f 'os_unix.c' || echo './'`os_unix.c
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -g -O2 -Wall -MT libfcgi_la-os_unix.lo -MD -MP -MF .deps/libfcgi_la-os_unix.Tpo -c os_unix.c -fPIC -DPIC -o .libs/libfcgi_la-os_unix.o
os_unix.c: In function 'OS_Accept':
os_unix.c:1175:54: warning: pointer targets in passing argument 3 of 'accept' differ in signedness [-Wpointer-sign]
socket = accept(listen_sock, (struct sockaddr *)&sa, &len);
^
In file included from /usr/include/netinet/in.h:23:0,
from os_unix.c:28:
/usr/include/x86_64-linux-gnu/sys/socket.h:243:12: note: expected 'socklen_t * __restrict__' but argument is of type 'int *'
extern int accept (int __fd, __SOCKADDR_ARG __addr,
^
os_unix.c: In function 'OS_IsFcgi':
os_unix.c:1275:35: warning: pointer targets in passing argument 3 of 'getpeername' differ in signedness [-Wpointer-sign]
if (getpeername(sock, (struct sockaddr *)&sa, &len) != 0 && errno == ENOTCONN) {
^
In file included from /usr/include/netinet/in.h:23:0,
from os_unix.c:28:
/usr/include/x86_64-linux-gnu/sys/socket.h:141:12: note: expected 'socklen_t * __restrict__' but argument is of type 'int *'
extern int getpeername (int __fd, __SOCKADDR_ARG __addr,
^
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -g -O2 -Wall -MT libfcgi_la-os_unix.lo -MD -MP -MF .deps/libfcgi_la-os_unix.Tpo -c os_unix.c -o libfcgi_la-os_unix.o >/dev/null 2>&1
mv -f .deps/libfcgi_la-os_unix.Tpo .deps/libfcgi_la-os_unix.Plo
/bin/bash ../libtool --tag=CC --mode=link gcc -pthread -g -O2 -Wall -o libfcgi.la -rpath /usr/local/lib libfcgi_la-fcgiapp.lo libfcgi_la-fcgi_stdio.lo libfcgi_la-os_unix.lo -lnsl
gcc -shared .libs/libfcgi_la-fcgiapp.o .libs/libfcgi_la-fcgi_stdio.o .libs/libfcgi_la-os_unix.o -lnsl -pthread -Wl,-soname -Wl,libfcgi.so.0 -o .libs/libfcgi.so.0.0.0
(cd .libs && rm -f libfcgi.so.0 && ln -s libfcgi.so.0.0.0 libfcgi.so.0)
(cd .libs && rm -f libfcgi.so && ln -s libfcgi.so.0.0.0 libfcgi.so)
ar cru .libs/libfcgi.a libfcgi_la-fcgiapp.o libfcgi_la-fcgi_stdio.o libfcgi_la-os_unix.o
ranlib .libs/libfcgi.a
creating libfcgi.la
(cd .libs && rm -f libfcgi.la && ln -s ../libfcgi.la libfcgi.la)
/bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT fcgio.lo -MD -MP -MF .deps/fcgio.Tpo -c -o fcgio.lo fcgio.cpp
g++ -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT fcgio.lo -MD -MP -MF .deps/fcgio.Tpo -c fcgio.cpp -fPIC -DPIC -o .libs/fcgio.o
g++ -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT fcgio.lo -MD -MP -MF .deps/fcgio.Tpo -c fcgio.cpp -o fcgio.o >/dev/null 2>&1
mv -f .deps/fcgio.Tpo .deps/fcgio.Plo
/bin/bash ../libtool --tag=CXX --mode=link g++ -g -O2 -lfcgi -rpath /usr/local/lib -o libfcgi++.la fcgio.lo -lnsl
g++ -shared -nostdlib /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbeginS.o .libs/fcgio.o -Wl,--rpath -Wl,/home/three/WorkSpace/nginx/libfcgi-master/libfcgi/.libs /home/three/WorkSpace/nginx/libfcgi-master/libfcgi/.libs/libfcgi.so -lnsl -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-linux-gnu/4.8/crtendS.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o -Wl,-soname -Wl,libfcgi++.so.0 -o .libs/libfcgi++.so.0.0.0
(cd .libs && rm -f libfcgi++.so.0 && ln -s libfcgi++.so.0.0.0 libfcgi++.so.0)
(cd .libs && rm -f libfcgi++.so && ln -s libfcgi++.so.0.0.0 libfcgi++.so)
ar cru .libs/libfcgi++.a fcgio.o
ranlib .libs/libfcgi++.a
creating libfcgi++.la
(cd .libs && rm -f libfcgi++.la && ln -s ../libfcgi++.la libfcgi++.la)
make[2]: Leaving directory `/home/three/WorkSpace/nginx/libfcgi-master/libfcgi'
Making all in cgi-fcgi
make[2]: Entering directory `/home/three/WorkSpace/nginx/libfcgi-master/cgi-fcgi'
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -Wall -MT cgi-fcgi.o -MD -MP -MF .deps/cgi-fcgi.Tpo -c -o cgi-fcgi.o cgi-fcgi.c
cgi-fcgi.c: In function ‘WebServerReadHandler’:
cgi-fcgi.c:390:13: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
= MakeHeader(FCGI_STDIN, requestId, bytesRead, 0);
^
cgi-fcgi.c: In function ‘ScheduleIo’:
cgi-fcgi.c:461:5: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
(ClientData)appServerSock) == -1) {
^
cgi-fcgi.c:477:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
(ClientData)appServerSock) == -1) {
^
cgi-fcgi.c: In function ‘ParseArgs’:
cgi-fcgi.c:643:9: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t’ [-Wformat=]
strlen(tp1)+1);
^
cgi-fcgi.c: In function ‘main’:
cgi-fcgi.c:725:9: warning: variable ‘numFDs’ set but not used [-Wunused-but-set-variable]
int numFDs;
^
mv -f .deps/cgi-fcgi.Tpo .deps/cgi-fcgi.Po
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -Wall -o cgi-fcgi cgi-fcgi.o ../libfcgi/libfcgi.la -lnsl
mkdir .libs
gcc -g -O2 -Wall -o .libs/cgi-fcgi cgi-fcgi.o ../libfcgi/.libs/libfcgi.so -lnsl
creating cgi-fcgi
make[2]: Leaving directory `/home/three/WorkSpace/nginx/libfcgi-master/cgi-fcgi'
Making all in examples
make[2]: Entering directory `/home/three/WorkSpace/nginx/libfcgi-master/examples'
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -Wall -MT authorizer.o -MD -MP -MF .deps/authorizer.Tpo -c -o authorizer.o authorizer.c
mv -f .deps/authorizer.Tpo .deps/authorizer.Po
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -Wall -o authorizer authorizer.o ../libfcgi/libfcgi.la -lnsl
mkdir .libs
gcc -g -O2 -Wall -o .libs/authorizer authorizer.o ../libfcgi/.libs/libfcgi.so -lnsl
creating authorizer
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -Wall -MT echo.o -MD -MP -MF .deps/echo.Tpo -c -o echo.o echo.c
mv -f .deps/echo.Tpo .deps/echo.Po
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -Wall -o echo echo.o ../libfcgi/libfcgi.la -lnsl
gcc -g -O2 -Wall -o .libs/echo echo.o ../libfcgi/.libs/libfcgi.so -lnsl
creating echo
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -Wall -MT echo-x.o -MD -MP -MF .deps/echo-x.Tpo -c -o echo-x.o echo-x.c
mv -f .deps/echo-x.Tpo .deps/echo-x.Po
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -Wall -o echo-x echo-x.o ../libfcgi/libfcgi.la -lnsl
gcc -g -O2 -Wall -o .libs/echo-x echo-x.o ../libfcgi/.libs/libfcgi.so -lnsl
creating echo-x
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -Wall -MT log-dump.o -MD -MP -MF .deps/log-dump.Tpo -c -o log-dump.o log-dump.c
mv -f .deps/log-dump.Tpo .deps/log-dump.Po
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -Wall -o log-dump log-dump.o ../libfcgi/libfcgi.la -lnsl
gcc -g -O2 -Wall -o .libs/log-dump log-dump.o ../libfcgi/.libs/libfcgi.so -lnsl
creating log-dump
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -Wall -MT size.o -MD -MP -MF .deps/size.Tpo -c -o size.o size.c
mv -f .deps/size.Tpo .deps/size.Po
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -Wall -o size size.o ../libfcgi/libfcgi.la -lnsl
gcc -g -O2 -Wall -o .libs/size size.o ../libfcgi/.libs/libfcgi.so -lnsl
creating size
gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread -g -O2 -Wall -MT threaded-threaded.o -MD -MP -MF .deps/threaded-threaded.Tpo -c -o threaded-threaded.o `test -f 'threaded.c' || echo './'`threaded.c
threaded.c: In function ‘doit’:
threaded.c:27:28: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
int rc, i, thread_id = (int)a;
^
threaded.c: In function ‘main’:
threaded.c:80:44: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
pthread_create(&id[i], NULL, doit, (void*)i);
^
mv -f .deps/threaded-threaded.Tpo .deps/threaded-threaded.Po
/bin/bash ../libtool --tag=CC --mode=link gcc -pthread -g -O2 -Wall -pthread -o threaded threaded-threaded.o ../libfcgi/libfcgi.la -lnsl
gcc -pthread -g -O2 -Wall -pthread -o .libs/threaded threaded-threaded.o ../libfcgi/.libs/libfcgi.so -lnsl
creating threaded
g++ -DHAVE_CONFIG_H -I. -I.. -I../include -g -O2 -MT echo-cpp.o -MD -MP -MF .deps/echo-cpp.Tpo -c -o echo-cpp.o echo-cpp.cpp
mv -f .deps/echo-cpp.Tpo .deps/echo-cpp.Po
/bin/bash ../libtool --tag=CXX --mode=link g++ -g -O2 -o echo-cpp echo-cpp.o ../libfcgi/libfcgi++.la -lnsl
g++ -g -O2 -o .libs/echo-cpp echo-cpp.o ../libfcgi/.libs/libfcgi++.so -lnsl
/usr/bin/ld: echo-cpp.o: undefined reference to symbol 'FCGX_InitRequest'
//home/three/WorkSpace/nginx/libfcgi-master/libfcgi/.libs/libfcgi.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [echo-cpp] Error 1
make[2]: Leaving directory `/home/three/WorkSpace/nginx/libfcgi-master/examples'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/three/WorkSpace/nginx/libfcgi-master'
make: *** [all] Error 2
there's no FCGX_Open*
in https://github.com/toshic/libfcgi/blob/master/examples/threaded.c ,
seems something is missing?
I saw many people start the fcgi script by spawn-fcgi, why this library dose not support creating a tcp socket or an unix domain socket, so that I do not need to adopt too many thirdparty modules in my project?
Здравствуйте!
Что изменилось в проекте после доработки Яндексом? Спасибо.
ASSERT(size == 0 || result != NULL);
Won't this assertion fail when you try to allocate anything more than 0 bytes? Shouldn't it be ASSERT(size != 0 || result != NULL)?
If this is intentional, can you explain why?
Hey,man.
When I make this project with gcc v4.8.4,errors occured as below:
make[2]: Entering directory /home/test/Downloads/web-c/libfcgi-master/examples' /bin/bash ../libtool --tag=CXX --mode=link g++ -g -O2 -o echo-cpp echo-cpp.o ../libfcgi/libfcgi++.la -lnsl g++ -g -O2 -o .libs/echo-cpp echo-cpp.o ../libfcgi/.libs/libfcgi++.so -lnsl /usr/bin/ld: echo-cpp.o: undefined reference to symbol 'FCGX_InitRequest' //home/test/Downloads/web-c/libfcgi-master/libfcgi/.libs/libfcgi.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make[2]: *** [echo-cpp] Error 1 make[2]: Leaving directory
/home/test/Downloads/web-c/libfcgi-master/examples'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/test/Downloads/web-c/libfcgi-master'
make: *** [all] Error 2
I think something wrong with echo-cpp.cpp.
When I cross-compile this project with armv7l-timesys-linux-gnueabi(./configure --host=armv7l-timesys-linux-gnueabi --prefix=/ufs/libfcgi1/ and make),
errors occured as below:
make[2]: Entering directory /home/test/Downloads/web-c/libfcgi-master/examples' /bin/bash ../libtool --tag=CXX --mode=link armv7l-timesys-linux-gnueabi-g++ -g -O2 -o echo-cpp echo-cpp.o ../libfcgi/libfcgi++.la -lnsl armv7l-timesys-linux-gnueabi-g++ -g -O2 -o .libs/echo-cpp echo-cpp.o ../libfcgi/.libs/libfcgi++.so -lnsl -Wl,--rpath -Wl,/ufs/libfcgi1//lib /home/test/Downloads/toolchain/bin/../lib/gcc/armv7l-timesys-linux-gnueabi/4.7.3/../../../../armv7l-timesys-linux-gnueabi/bin/ld: warning: libfcgi.so.0, needed by ../libfcgi/.libs/libfcgi++.so, not found (try using -rpath or -rpath-link) echo-cpp.o: In function
main':
/home/test/Downloads/web-c/libfcgi-master/examples/echo-cpp.cpp:110: undefined reference to FCGX_Init' /home/test/Downloads/web-c/libfcgi-master/examples/echo-cpp.cpp:111: undefined reference to
FCGX_InitRequest'
/home/test/Downloads/web-c/libfcgi-master/examples/echo-cpp.cpp:113: undefined reference to FCGX_Accept_r' echo-cpp.o: In function
gstdin':
/home/test/Downloads/web-c/libfcgi-master/examples/echo-cpp.cpp:60: undefined reference to FCGX_GetParam' echo-cpp.o: In function
main':
/home/test/Downloads/web-c/libfcgi-master/examples/echo-cpp.cpp:113: undefined reference to FCGX_Accept_r' echo-cpp.o: In function
gstdin':
/home/test/Downloads/web-c/libfcgi-master/examples/echo-cpp.cpp:69: undefined reference to FCGX_GetParam' ../libfcgi/.libs/libfcgi++.so: undefined reference to
FCGX_PutChar'
../libfcgi/.libs/libfcgi++.so: undefined reference to FCGX_FFlush' ../libfcgi/.libs/libfcgi++.so: undefined reference to
FCGX_GetStr'
../libfcgi/.libs/libfcgi++.so: undefined reference to FCGX_GetChar' ../libfcgi/.libs/libfcgi++.so: undefined reference to
FCGX_PutStr'
collect2: error: ld returned 1 exit status
make[2]: *** [echo-cpp] Error 1
make[2]: Leaving directory /home/test/Downloads/web-c/libfcgi-master/examples' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory
/home/test/Downloads/web-c/libfcgi-master'
make: *** [all] Error 2
Also in the echo-cpp.cpp.
Can you help me with this?
Did I go wrong with something?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.