gpertea / gclib Goto Github PK
View Code? Open in Web Editor NEWGCLib - Genomic C++ library of reusable code for bioinformatics projects
License: Other
GCLib - Genomic C++ library of reusable code for bioinformatics projects
License: Other
Originally posted by @Maarten-vd-Sande in gpertea/gffread#21 (comment)
Just dropping in to say that supporting multiple tables would be an awesome feature (for me). I haven't found any other tool that works as easy and fast as gffread.
Would you support a PR in this direction, if so, can you give some pointers? It's been over 5 years since I did anything serious with C++ so it might not result into anything useful though 😇 .. I can't seem to find where the table is defined..
Line 7 in f6817ea
Hi,
please consider the following patch. You use CC instead of CXX, CFLAGS instead of CXXFLAGS. Moreover, please do not overwrite their values if they are already set.
https://github.com/gentoo/sci/blob/master/sci-biology/gclib/files/Makefile.patch
PoC Input: min.gz
Steps to Reproduce:
gzip -d min.gz
./gffread -E min -o out
Output:
Command line was:
./gffread -E min -o out
Segmentation fault
Lines 413 to 432 in 8aee376
When GCLib reads a GFF line with no info segment, the char *
at t[8]
will not be set, causing it to take on whatever stale value happens to be in that location of the stack. Triggered accidentally, this can cause a segfault due to reading an invalid address here:
Line 118 in 8aee376
However, a maliciously crafted input may be able to place a valid pointer at this location, causing a more severe vulnerability.
At a minimum, t
should be zeroed during initialization:
*** v0.12.7/gclib/gff.cpp 2021-07-23 10:31:39.000000000 -0400
--- new/gclib/gff.cpp 2021-10-04 10:54:52.989309121 -0400
*************** GffLine::GffLine(GffReader* reader, cons
*** 405,411 ****
GMALLOC(dupline, llen+1);
memcpy(dupline, l, llen+1);
skipLine=true; //clear only if we make it to the end of this function
! char* t[9];
int i=0;
int tidx=1;
t[0]=line;
--- 405,411 ----
GMALLOC(dupline, llen+1);
memcpy(dupline, l, llen+1);
skipLine=true; //clear only if we make it to the end of this function
! char* t[9] = {0};
int i=0;
int tidx=1;
t[0]=line;
Ideally, the library should gracefully handle no info being found (this only works if t
is zero initialized):
*** v0.12.7/gclib/gff.cpp 2021-07-23 10:31:39.000000000 -0400
--- new/gclib/gff.cpp 2021-10-04 10:54:52.989309121 -0400
*************** GffLine::GffLine(GffReader* reader, cons
*** 430,435 ****
--- 430,439 ----
track=t[1];
ftype=t[2];
info=t[8];
+ if (!info) {
+ GMessage("Warning: missing info:\n%s\n",l);
+ return;
+ }
char* p=t[3];
if (!parseUInt(p,fstart)) {
//chromosome_band entries in Flybase
Hello,
Admittedly, I do not see any immediate need to address any of these warnings.
Kind regards,
Steffen
$ gcc --version
gcc (Debian 10.2.0-3) 10.2.0
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I. -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/home/moeller/git/med-team/libgclib=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -pedantic -flto -fPIC -D_FILE_OFFSET_BITS=64 -c GStr.cpp -fPIC -DPIC -o .libs/libgclib_la-GStr.o
In file included from gff.cpp:1:
gff.h:229:13: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
229 | struct {
| ^
gff.h:232:13: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
232 | struct {
| ^
gff.h:328:12: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
328 | struct {
| ^
gff.h:691:14: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
691 | struct {
| ^
gff.h:1150:12: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
1150 | struct {
| ^
In file included from GList.hh:8,
from GFastaIndex.h:12,
from GFaSeqGet.h:3,
from gff.h:9,
from gff.cpp:1:
GVec.hh: In instantiation of ‘void GVec<OBJ>::setCapacity(int) [with OBJ = GMapSeg]’:
GVec.hh:202:3: required from ‘GVec<OBJ>::GVec(int) [with OBJ = GMapSeg]’
gff.h:127:50: required from here
GVec.hh:291:15: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class GMapSeg’; use assignment or value-initialization instead [-Wclass-memaccess]
291 | memset(fArray+fCount, 0, (NewCapacity-fCount)*sizeof(OBJ));
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from gff.cpp:1:
gff.h:70:7: note: ‘class GMapSeg’ declared here
70 | class GMapSeg:public GSeg {
| ^~~~~~~
In file included from GList.hh:8,
from GFastaIndex.h:12,
from GFaSeqGet.h:3,
from gff.h:9,
from gff.cpp:1:
GVec.hh: In instantiation of ‘void GVec<OBJ>::setCapacity(int) [with OBJ = GSeg]’:
GVec.hh:202:3: required from ‘GVec<OBJ>::GVec(int) [with OBJ = GSeg]’
gff.h:311:92: required from here
GVec.hh:291:15: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class GSeg’; use assignment or value-initialization instead [-Wclass-memaccess]
291 | memset(fArray+fCount, 0, (NewCapacity-fCount)*sizeof(OBJ));
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from gff.h:6,
from gff.cpp:1:
GBase.h:308:7: note: ‘class GSeg’ declared here
308 | class GSeg {
| ^~~~
In file included from GList.hh:8,
from GFastaIndex.h:12,
from GFaSeqGet.h:3,
from gff.h:9,
from gff.cpp:1:
GVec.hh: In instantiation of ‘void GVec<OBJ>::setCapacity(int) [with OBJ = GeneCDS]’:
GVec.hh:202:3: required from ‘GVec<OBJ>::GVec(int) [with OBJ = GeneCDS]’
gff.h:1351:31: required from here
GVec.hh:291:15: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class GeneCDS’; use assignment or value-initialization instead [-Wclass-memaccess]
291 | memset(fArray+fCount, 0, (NewCapacity-fCount)*sizeof(OBJ));
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from gff.cpp:1:
gff.h:1340:7: note: ‘class GeneCDS’ declared here
1340 | class GeneCDS: public GSeg {
| ^~~~~~~
In file included from GList.hh:8,
from GFastaIndex.h:12,
from GFaSeqGet.h:3,
from gff.h:9,
from gff.cpp:1:
GVec.hh: In instantiation of ‘void GVec<OBJ>::setCapacity(int) [with OBJ = GffExon]’:
GVec.hh:202:3: required from ‘GVec<OBJ>::GVec(int) [with OBJ = GffExon]’
gff.cpp:2315:16: required from here
GVec.hh:291:15: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class GffExon’; use assignment or value-initialization instead [-Wclass-memaccess]
291 | memset(fArray+fCount, 0, (NewCapacity-fCount)*sizeof(OBJ));
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from gff.cpp:1:
gff.h:629:7: note: ‘class GffExon’ declared here
629 | class GffExon : public GSeg {
| ^~~~~~~
In file included from GList.hh:8,
from GFastaIndex.h:12,
from GFaSeqGet.h:3,
from gff.h:9,
from gff.cpp:1:
GVec.hh: In instantiation of ‘void GVec<OBJ>::setCapacity(int) [with OBJ = GSegMatch]’:
GVec.hh:202:3: required from ‘GVec<OBJ>::GVec(int) [with OBJ = GSegMatch]’
GList.hh:191:76: required from ‘GArray<OBJ>::GArray(int (*)(pointer, pointer)) [with OBJ = GSegMatch; GCompareProc = int(void*, void*); pointer = void*]’
gff.h:1351:31: required from here
GVec.hh:291:15: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class GSegMatch’; use assignment or value-initialization instead [-Wclass-memaccess]
291 | memset(fArray+fCount, 0, (NewCapacity-fCount)*sizeof(OBJ));
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from gff.cpp:1:
gff.h:1328:7: note: ‘class GSegMatch’ declared here
1328 | class GSegMatch { //keep track of "matching" overlaps of a GeneCDSChain with multiple GeneSegment containers
| ^~~~~~~~~
In file included from GList.hh:8,
from GFastaIndex.h:12,
from GFaSeqGet.h:3,
from gff.h:9,
from gff.cpp:1:
GVec.hh: In instantiation of ‘void GVec<OBJ>::Grow(int, OBJ&) [with OBJ = GSegMatch]’:
GVec.hh:437:9: required from ‘void GVec<OBJ>::Insert(int, OBJ*) [with OBJ = GSegMatch]’
GVec.hh:69:44: required from ‘void GVec<OBJ>::Insert(int, OBJ) [with OBJ = GSegMatch]’
GList.hh:234:21: required from ‘int GArray<OBJ>::Add(OBJ*) [with OBJ = GSegMatch]’
GList.hh:51:36: required from ‘int GArray<OBJ>::Add(OBJ&) [with OBJ = GSegMatch]’
gff.h:1364:22: required from here
GVec.hh:358:15: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class GSegMatch’; use assignment or value-initialization instead [-Wclass-memaccess]
358 | memset(&newList[fCount+1], 0, (NewCapacity-fCount-1)*sizeof(OBJ));
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from gff.cpp:1:
gff.h:1328:7: note: ‘class GSegMatch’ declared here
1328 | class GSegMatch { //keep track of "matching" overlaps of a GeneCDSChain with multiple GeneSegment containers
| ^~~~~~~~~
The current Makefile does not allow to build gffcompare. Some extra .o / .so files need to be created.
For a recent bioconda package I commited the following patch to get it (hopefully running):
https://github.com/bioconda/bioconda-recipes/pull/12416/files#diff-bf53084914598c421a598e57f68431ae
.. maybe include just all objects .. ?
Can you please tag a release of this software? We'd like to user gffread and build it consistently with a tagged version of this lib. Tags are much nicer than using commit hashes...
During building a new conda package for this library (bioconda/bioconda-recipes#12416) I had the problem that the compiler reported an ambiguous namespace for chrono.
Could you change this to a subnamespace as my patch here:
or use the std::chrono and std::ratio namespaces?
Specifically for addPadding
and removePadding
support.
This will allow us to update the packages in Debian; thanks!
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.