Patch Set 1: Code-Review-1

(4 comments)

https://gerrit.osmocom.org/#/c/5878/1/src/libosmo-mgcp/mgcp_protocol.c
File src/libosmo-mgcp/mgcp_protocol.c:

Line 1217:      len = snprintf(buf, sizeof(buf),
snprintf() could return -1 here if the expanded string does not fit into buf.


Line 1220:      rc = send_agent(cfg, buf, len);
Which means we could end up passing -1 as length here...

I suggest returning an error if snprintf() returns -1.


Line 1240:      if (len < 0)
Here it is done correctly.


Line 1243:      buf[sizeof(buf) - 1] = '\0';
Unrelated to your change, but this line is not needed with snprintf() and could 
be removed.

Adding a NUL manually is a common idiom after calling strncpy() because 
strncpy() does not always NUL-terminate the string. But snprintf() is fine.


-- 
To view, visit https://gerrit.osmocom.org/5878
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ia91ac428ba83ac1f9b52a0ec8dbf00ef7876da9e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Stefan Sperling <ssperl...@sysmocom.de>
Gerrit-HasComments: Yes

Reply via email to