rsyslog / rsyslog/libfastjson

va_start and va_end should be in one block of code

Open Beginner friendly
#154 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
61
Forks
35
Avg merge
21m
Merged PRs (30d)
2

Description

In printbuf.c, sprintbuf() this piece of code might not compile or work as expected everywhere:

va_start(ap, msg);
if((size = vasprintf(&t, msg, ap)) < 0) { va_end(ap); return -1; }
va_end(ap);

From the man page:

On some systems, va_end contains a closing '}' matching a '{' in va_start, so that both macros must  occur  in the same function, and in a way that allows this.

Should be

va_start(ap, msg);
size = vasprintf(&t, msg, ap);
va_end(ap);
if(size < 0) return -1;

I didn't check if that kind of code is used somewhere - it was just a random encounter.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open printbuf.c and inspect sprintbuf() around the va_start, vasprintf, and va_end calls. Search the file for other va_start/va_end usage and check the project's build or tests if available. Done means the variadic macros are used in a portable arrangement and the library still builds successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.