New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CSV escaping function #53

ghost opened this Issue Oct 4, 2015 · 0 comments


None yet
0 participants

ghost commented Oct 4, 2015

I had problems with CSV output. I analyzed the source code and did some debugging and then I realized, that the bug #36 was already fixed upstream and it "just" remains in distributions.

But anyway the function csv_escape() IMHO should be improved or at least well documented because it has some subtle limitations:

  • the input length is checked against MAX_STRLEN but during escaping the length grows so it will not fit into the char csv[MAX_STRLEN+1]. Of course, current filesystems have also limitations so it might not be an issue. But the limits could be checked inside the loop. And on the other hand, the strlen(string) could be done only once (outside the loop).
  • using static local variables and returning pointers to them from the function might lead (and really leads, as seen in #36) to very unexpected behavior. What about passing the buffer from outside the function as its parameter?

BTW: are you going to release 3.15? (according to the wiki, the last released version is still 3.14 from 2010)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment