hat jemand eine ahnung was gemeint sein koennte?
ZitatAlles anzeigen
> in line 428 there is the following code:
> /* config file is ~/.bti */
> file = alloca(strlen(session->homedir) + 7); > sprintf(file, "%s/.bti",session->homedir);Ugh, that's some horrible code, you really don't want to be reading it
> "/.bti" makes 5 chars + 1 for '\0' makes 6, but you allocate 7 bytes.
> the same thing in line 558:
> filename = alloca(strlen(session->homedir) + > strlen(session->logfile) + 3); >sprintf(filename, "%s/%s", session->homedir, session->logfile);
> the two strings + '/' + '\0' make +2, but you allocate +3
> I am sure there is something I missed, but I don't get it :-/
> any hints for a C n00b?
It's just being paranoid and allocating one extra byte just to be "safe".
Don't use it as a good example of coding style at all
in welchem fall koennte dieses extrabyte safer sein?