Comments (4)
And inttype.h is available? Otherwise the whole statement can't be parsed correctly. This could be checked within the DEBUG log.
Otherwise, this is the desired behavior with the new frontend.
from codepropertygraph.
If it does work when inttypes.h
is available, this begs the question of whether we should automatically include header files from certain standard locations - or even ship a bunch of standard headers. @max-leuthaeuser do you know what the state is here, currently? Are we looking in, e.g., /usr/include
?
from codepropertygraph.
As far as I know: Eclipse CDT does not include anything outside of the given directory by default.
We would have to set some defaults e.g., here: https://github.com/ShiftLeftSecurity/codepropertygraph/blob/master/c2cpg/src/main/scala/io/shiftleft/c2cpg/C2Cpg.scala#L70
from codepropertygraph.
With the latest c2cpg
this works now as expected if you have gcc
installed:
test.c:
#include <inttypes.h>
#include <stdio.h>
int main() {
char test[1024];
snprintf (test, sizeof(test), "abc %"PRIu64"", 123);
printf("%s", test);
}
[INFO ] Output file exists, removing: /tmp/cpg.bin
[INFO ] initializing 0 nodes from existing storage
[INFO ] installed GC monitors. will clear references if heap (after GC) is larger than 80%
[INFO ] Using the following system include paths:
- /usr/include/c++/11.1.0/x86_64-pc-linux-gnu
- /usr/include
- /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include-fixed
- /usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include
- /usr/local/include
- /usr/include/c++/11.1.0/backward
- /usr/include/c++/11.1.0
[INFO ] Running pass: io.shiftleft.semanticcpg.passes.frontend.MetaDataPass
[INFO ] Pass io.shiftleft.semanticcpg.passes.frontend.MetaDataPass completed in 26 milliseconds
[INFO ] Start of enhancement: io.shiftleft.c2cpg.passes.AstCreationPass
[INFO ] Parsed '/path/to/test.c' in 279.9 ms (0 preprocessor error(s), 0 problems)
[INFO ] Enhancement io.shiftleft.c2cpg.passes.AstCreationPass completed in 585 ms. 1328 changes commited from 1 parts.
[INFO ] Start of enhancement: io.shiftleft.c2cpg.passes.HeaderAstCreationPass
[INFO ] Enhancement io.shiftleft.c2cpg.passes.HeaderAstCreationPass completed in 2 ms. 0 changes commited from 0 parts.
[INFO ] Running pass: io.shiftleft.c2cpg.passes.HeaderContentLinkerPass
[INFO ] Pass io.shiftleft.c2cpg.passes.HeaderContentLinkerPass completed in 29 milliseconds
[INFO ] Running pass: io.shiftleft.semanticcpg.passes.frontend.TypeNodePass
[INFO ] Pass io.shiftleft.semanticcpg.passes.frontend.TypeNodePass completed in 4 milliseconds
[INFO ] serializing and persisting 934 nodes (this may take a while)
[INFO ] finished serializing and persisting 934 nodes
> cpg.method.external.name.p
res1: List[String] = List(
"imaxabs",
"imaxdiv",
"strtoimax",
"strtoumax",
"wcstoimax",
"wcstoumax",
"remove",
"rename",
"renameat",
"tmpfile",
"tmpnam",
"tmpnam_r",
"tempnam",
"fclose",
"fflush",
"fflush_unlocked",
"fopen",
"freopen",
"fdopen",
"fmemopen",
"open_memstream",
"setbuf",
"setvbuf",
"setbuffer",
"setlinebuf",
"fprintf",
"printf",
"sprintf",
"vfprintf",
"vprintf",
"vsprintf",
"snprintf",
"vsnprintf",
"vdprintf",
"dprintf",
"fscanf",
"scanf",
"sscanf",
"__isoc99_fscanf",
"__isoc99_scanf",
"__isoc99_sscanf",
"vfscanf",
"vscanf",
"vsscanf",
"__isoc99_vfscanf",
"__isoc99_vscanf",
"__isoc99_vsscanf",
"fgetc",
"getc",
"getchar",
"getc_unlocked",
"getchar_unlocked",
"fgetc_unlocked",
"fputc",
"putc",
"putchar",
"fputc_unlocked",
"putc_unlocked",
"putchar_unlocked",
"getw",
"putw",
"fgets",
"gets",
"__getdelim",
"getdelim",
"getline",
"fputs",
"puts",
"ungetc",
"fread",
"fwrite",
"fread_unlocked",
"fwrite_unlocked",
"fseek",
"ftell",
"rewind",
"fseeko",
"ftello",
"fgetpos",
"fsetpos",
"clearerr",
"feof",
"ferror",
"clearerr_unlocked",
"feof_unlocked",
"ferror_unlocked",
"perror",
"fileno",
"fileno_unlocked",
"popen",
"pclose",
"ctermid",
"flockfile",
"ftrylockfile",
"funlockfile",
"__uflow",
"__overflow"
)
Also:
> cpg.call.name.p
res2: List[String] = List("snprintf", "<operator>.sizeOf", "printf")
from codepropertygraph.
Related Issues (20)
- Warnings and crash when using the new C frontend with joern-scan on VLC HOT 9
- Possibly unwanted #ifdef behaviour when running joern-scan with new C frontend HOT 4
- cpgqls python client closes connection before queries finish HOT 1
- Some header files not found with new beta C/C++ frontend HOT 2
- New C frontend: `METHOD` stubs for external methods not present HOT 1
- New C/C++ frontend: missing TYPE nodes for lambdas/template-types
- [ newc ] Type is missing for locals
- newc: signature
- [newc] Base class in separate namespace not correctly identified
- Missing size of char array in CPG
- Question regarding `NodeRef`s HOT 2
- Does this tool support generating cpg from java code? HOT 2
- Errors during createAndApply of ParallelCpgPass not escalated HOT 9
- Wrong result for `\\` in the label in the dot file HOT 2
- Some operators have the wrong name (typo) HOT 1
- by using this joern library , i want CPG in ideal format as given in research papers in which CFG and AST nodes must not connected HOT 1
- Can code contain inheritance relationships between classes?
- `sbt package` failing on M1 macOS
- Introduce `POSSIBLE_TYPES` property
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codepropertygraph.