Here comes a bug while fuzzing Mosquitto lib, I would like to know the solution.
Step1. compile the lib
#:~/fuzz/fuzzmqtt/mosquitto$ ls
about.html doc Makefile security
aclfile.example docker man SECURITY.md
appveyor.yml edl-v10 misc service
buildtest.py epl-v10 mosquitto.conf set-version.sh
ChangeLog.txt examples Mosquitto.podspec snap
client installer notice.html src
CMakeLists.txt lib pskfile.example test
compiling.txt libmosquitto.pc.in pwfile.example THANKS.txt
config.h libmosquittopp.pc.in readme.md travis-configure.sh
config.mk LICENSE.txt readme-tests.md travis-install.sh
CONTRIBUTING.md logo readme-windows.txt www
#:~/fuzz/fuzzmqtt/mosquitto$ sudo make install CC="clang -O2 -fno-omit-frame-pointer -g -fsanitize=address -fsanitize-coverage=trace-pc-guard,trace-cmp,trace-gep,trace-div" -j2
Step2. compile the fuzzer
#:~/fuzz/fuzzmqtt/mosquitto/lib$ clang -g -O1 -fsanitize=fuzzer,address mos_fuzzer.cc -o mos_fuzzer -lmosquitto
Step3. Run the fuzzer and got the bug
#~/fuzz/fuzzmqtt/mosquitto/lib$ ./mos_fuzzer
INFO: Seed: 106983829
INFO: Loaded 1 modules (2337 guards): 2337 [0x7f157cd816b0, 0x7f157cd83b34),
INFO: Loaded 1 modules (1 inline 8-bit counters): 1 [0x787f80, 0x787f81),
INFO: Loaded 1 PC tables (1 PCs): 1 [0x565af8,0x565b08),
ERROR: The size of coverage PC tables does not match the
number of instrumented PCs. This might be a compiler bug,
please contact the libFuzzer developers.
Also check https://bugs.llvm.org/show_bug.cgi?id=34636
for possible workarounds (tl;dr: don't use the old GNU ld)
The code is as follow
#include "stdio.h"
#include "mosquitto.h"
#include "assert.h"
#include "stdint.h"
#include "stddef.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
bool clean_session = true;
struct mosquitto *mosq = NULL;
mosquitto_lib_init();
void *data_1=(void *)data;
mosq = mosquitto_new(NULL, clean_session, data_1);
mosquitto_destroy(mosq);
mosquitto_lib_cleanup();
return 0;
}
Thank you
Related
I created the simplest external kernel module for my Raspberry PI as a test:
#include <linux/module.h>
#include <linux/kernel.h>
int hello_init(void) {
printk("Hello World");
return 0;
}
void hello_exit(void) {
printk("Goodbye World!");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
I complied it successfully with the following line:
sudo make -C /lib/modules/$(uname -r)/build M=$PWD modules
I tried to use sudo insmod hello.ko, and got the following error:
insmod: ERROR: could not insert module hello.ko: Invalid module format
And following this error in dmesg:
hello: disagrees about version of symbol module_layout
I've read everything there is to read about this error online. All the research has yielded the assumption that this is caused by compiling the module against a kernel which differs from the running kernel in either version or configuration.
However, this is absolutely not my case. The running kernel was loaded by the distribution and was not changed by me (Raspberry PI 3). Moreover, inspection of the kernel's other modules and hello.ko (using modinfo) is yielding the exact same vermagic and flags, which are:
vermagic: 5.15.33-v8+ SMP preempt mod_unload modversions aarch64
Since all online material originates this fault in version difference, I'm at a lost.
I have stucked a problem. I develop cross-compile for the embedded system. I built the opencv for arm_linux-gnueabihf.
My ubuntu version is 18.04.2 x86_64 5.3.0.51-generic.
The problem that
libopencv_highgui.so.3.4: cannot open shared object file: No such file or directory
I build the project success but when I run the project, I get the problem
this my code
#include <iostream>
#include <stdio.h>
#include <cv.h>
#include <opencv2/videoio.hpp>
#include <opencv2/core.hpp>
#include <opencv2/core/mat.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main(int, char**){
Mat frame;
VideoCapture cap;
int deviceId = 0;
int apiId = cv::CAP_ANY;
cap.open(deviceId,apiId);
if (!cap.isOpened()){
cerr<<"Error! Unable to camera\n";
return -1;
}
for(;;){
// read frame
cap.read(frame);
if (frame.empty()){
cerr <<" ERROR ! black frame grabbed ! \n";
break;
}
imshow("Live",frame);
if (waitKey(5) >= 0){
break;
}
}
return 0;
}
I checked the library as follows:
sudo find / -name "libopencv_highgui.so.3.4"
the command returned as follows
/usr/local/lib/libopencv_highgui.so.3.4
/usr/local/lib/libopencv_highgui.so.3.4.4
/usr/local/include/lib/libopencv_highgui.so.3.4
/usr/local/include/lib/libopencv_highgui.so.3.4.4
I created a file in /etc/ld.so.conf.d/opencv.conf that contain
/usr/local/lib
/usr/local/include
then I run the command that sudo ldconfig -v, and it returned as follow
/sbin/ldconfig.real: /usr/local/lib/libopencv_highgui.so.3.4.4 is for unknown machine 40.
/sbin/ldconfig.real: /usr/local/lib/libopencv_imgproc.so is for unknown machine 40.
/sbin/ldconfig.real: /usr/local/lib/libopencv_xfeatures2d.so is for unknown machine 40.
/sbin/ldconfig.real: /usr/local/lib/libopencv_bgsegm.so.3.4.4 is for unknown machine 40.
/sbin/ldconfig.real: /usr/local/lib/libopencv_objdetect.so.3.4 is for unknown machine 40.
and also other opencv's libraries.
I configured setting of the eclipse for the libraries as follows:
the "Includes" folder that in cross G++ Compiler
"Libraries" folder that in cross G++ Linker
Finally, I added the LD_LIBRARY_PATH in debug of the eclipse setting
I tried sudo apt update and sudo apt upgrade commands,but I still getting the error.
Does any one have any advice ?
the solution is add the "/usr/local/lib" to LD_LIBRARY_PATH in environment.
mine is
LD_LIBRARY_PATH /usr/arm-linux-gnueabihf/lib/:usr/local/lib/
I am trying to install module Algorithm::SVM from CPAN but I get the error listed below. At the message it says "failed". What may be the error?
*kadir#kadir-Inspiron-N5010:cpan install Algorithm::SVM
Reading '/home/kadir/.cpan/Metadata'
Database was generated on Thu, 07 Jan 2016 07:54:01 GMT
Running install for module 'Algorithm::SVM'
......
Makefile:350: recipe for target 'bindings.o' failed
make: *** [bindings.o] Error 1
LAIRDM/Algorithm-SVM-0.13.tar.gz
/usr/bin/make -- NOT OK*
If you are using Debian go to the build location of the module(after you ran cpan Algorithm::SVM ):
sudo vim /home/youruser/.cpan/build/Algorithm-SVM-0.13-biHfmx/bindings.h
Add these two lines in this area:
using namespace std;
#include <vector>
#include <map>
#include <assert.h>
#include <cstdlib> <===== Add these
#include <string.h> <===== two lines
Save and exit and the rebuild the module from here:
sudo make
sudo make install
Test if the installation is successful:
sudo cpan Algorithm::SVM
Here is a more detailed explanation concerning this issue: https://rt.cpan.org/Public/Bug/Display.html?id=43669
I am using eclipse luna on win 7.
Here is my program.
#include <iostream>
#include <boost/asio.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
int main(int argc, char* argv[]){
// All programs that use asio need to have at least one io_service object
boost::asio::io_service io;
// sets the timer to expire 5 seconds from now
boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
t.wait();
std::cout << "Hello, world!\n";
return 0;
}
Here is my command line code
g++ -I"C:\Users\Documents\Lib\boost_1_57_0\boost_1_57_0" -O0 -g3 -Wall -c -fmessage-length=0 -lboost_filesystem -lboost_system -lboost_libraryname -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
Invoking: Cross G++ Linker
g++ -o "002_TimerSynchronously" ./main.o
Error
C:/Users/SulfredLee/Documents/Lib/boost_1_57_0/boost_1_57_0/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
C:/Users/SulfredLee/Documents/Lib/boost_1_57_0/boost_1_57_0/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
C:/Users/SulfredLee/Documents/Lib/boost_1_57_0/boost_1_57_0/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
Anyone knows how to fix it?
Thank you very much
Reference:
undefined reference to boost::system::system_category() when compiling
How do I troubleshoot boost library/header inclusion via autoconf/automake?
The libraries should be present in the second command line when the linking takes place. Please be also careful and list the libraries after the object file.
I am using active perl 5.14.2. Here I am trying to use a windows C library in my perl code using Inline::C
use strict;
use Inline C => DATA =>
CCFLAGS => '-std:C99 -Tx86-coff -Zi -Ob1 -fp:precise -W1 -Gd -Ze -Go -D_USER_SPACE_' =>
INC => '"-ID:\test\incl"' =>
LIBS => '"-LD:\test\lib" -llib1 -llib2 -llib3 -llib4';
test();
__END__
__C__
#include <incl/hd1.h>
#include <stdio.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
void test(void) {
.........
While I am trying to run the script its failing with below error
Warning. No Inline C functions bound to Perl in .\test.pl
Check your C function definition(s) for Inline compatibility
Microsoft (R) Program Maintenance Utility Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Perl5.14\bin\perl.exe C:\Perl5.14\lib\ExtUtils\xsubpp -typemap "C:\Perl5.14\lib\ExtUtils\typemap" test_pl_7fbb.xs > test_pl_7fbb.xsc && C:\Perl5.14\bin\perl.exe -M
ExtUtils::Command -e "mv" -- test_pl_7fbb.xsc test_pl_7fbb.c
cl -c -I"D:/test" "-ID:\test\incl" -std:C99 -Tx86-coff -Zi -Ob1 -fp:precise -W1 -Gd -Ze -Go -D_USER_SPACE_ -MD -Zi -DNDEBUG -O1 -DVERSIO
N=\"0.00\" -DXS_VERSION=\"0.00\" "-IC:\Perl5.14\lib\CORE" test_pl_7fbb.c
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\cl.EXE"' : return code '0xc0000135'
Stop.
A problem was encountered while attempting to compile and install your Inline
C code. The command that failed was:
C:\PROGRA~2\MICROS~1.0\VC\bin\nmake.exe > out.make 2>&1
The build directory was:
D:\test\_Inline\build\test_pl_7fbb
To debug the problem, cd to the build directory, and inspect the output files.
at .\test.pl line 0
...propagated at C:/Perl5.14/site/lib/Inline/C.pm line 772.
INIT failed--call queue aborted.
PS D:\cmapl_test> perl -v
This is perl 5, version 14, subversion 2 (v5.14.2) built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2011, Larry Wall
Binary build 1402 [295342] provided by ActiveState http://www.ActiveState.com
Built Oct 7 2011 15:49:44
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
I tried to build the test_pl_7fbb.c file using the command:
cl -c "-ID:\test" "-ID:\test\include" -std:C99 -Tx86-coff -Zi -Ob1 -fp:precise -W1 -
Gd -Ze -Go -D_USER_SPACE_ -MD -Zi -DNDEBUG -O1 "-DVERSION=0.00"
"-DXS_VERSION=0.00" "-IC:\Perl5.14\lib\CORE" test_pl_7fbb.c
It got completed without error.
My guess the option -I"D:/test" used by Inline while compiling is causing the issue.
Thanks in advance for any help on this.
You seem to have installed Visual C VC-9 (VS 2008), but last time I used Activeperl's Inline C it required VC-6.
If that's the reason, you could try to install VC 6 or switch to Strawberry Perl which has the gcc 4.6 tool chain included.
You could try installing MinGW from ActivePerl's PPM servers. It would probably need a recompile of many of your installed modules to work, but i'm sure it'll make things like Inline::C work properly.