Coder Social home page Coder Social logo

alyptik / cepl Goto Github PK

View Code? Open in Web Editor NEW
19.0 19.0 4.0 11.22 MB

An interactive C (ISO/IEC 9899:2011) read–eval–print loop (REPL) currently supporting multiple compilers, shell-esque readline key-bindings/tab-completion, and incremental undo.

Home Page: https://alyp.tk/

License: GNU General Public License v3.0

Makefile 4.32% C 93.70% Roff 1.99%

cepl's People

Contributors

alyptik avatar mpan-pl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cepl's Issues

`getenv` result is modified

main.c:328: char *tmp_str = strcat(strcat(getenv("HOME"), "/"), HIST_NAME);
The result of getenv shouldn’t be modified, but two consecutive strcat calls modify it.

In my case the next environment variable available in the variables list is overwritten/damaged.

Ignoring above, no memory is reserved for appending strings with strcat.

SIGSEGV if `$HOME` isn’t defined

main.c:328: char *tmp_str = strcat(strcat(getenv("HOME"), "/"), HIST_NAME);
getenv returns NULL if $HOME isn’t present, but the code assumes a non-NULL value.

 $ valgrind ./cepl 
[…]
==28515== Command: ./cepl
==28515== 
==28515== Invalid read of size 1
==28515==    at 0x4C2F142: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==28515==    by 0x10AA27: main (in /home/user0/Desktop/cepl/cepl)
==28515==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==28515== 
==28515== 
==28515== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==28515==  Access not within mapped region at address 0x0
==28515==    at 0x4C2F142: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==28515==    by 0x10AA27: main (in /home/user0/Desktop/cepl/cepl)
[…]
Segmentation fault (core dumped)

Input skips trailing }

 $ ./cepl 

CEPL v3.1.1

>>> {;}

./cepl:



int main(int argc, char *argv[])
{
	/* silence -Wunused-parameter warning */
	(void)argc, (void)argv;

	{;

	return 0;
}

/dev/stdin: In function ‘main’:
/dev/stdin:51:1: error: expected declaration or statement at end of input
cepl: compiler returned non-zero exit code at line 89
exit status: 1

Expected result:

int main(int argc, char *argv[])
{
	/* silence -Wunused-parameter warning */
	(void)argc, (void)argv;

	{;}

	return 0;
}

and no error.

readline 7.0.003-1
gcc (GCC) 7.1.1 20170630

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.