Improve the printing of cmgs when the length is 0. Fix error handling.

This commit is contained in:
Michael Tuexen 2018-01-16 20:02:07 +00:00
parent 3193be242b
commit 6accaf4a90
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=328059

View File

@ -1493,10 +1493,15 @@ print_cmsgs(FILE *fp, pid_t pid, bool receive, struct msghdr *msghdr)
bool first;
len = msghdr->msg_controllen;
if (len == 0) {
fputs("{}", fp);
return;
}
cmsgbuf = calloc(1, len);
if (get_struct(pid, msghdr->msg_control, cmsgbuf, len) == -1) {
fprintf(fp, "%p", msghdr->msg_control);
free(cmsgbuf);
return;
}
msghdr->msg_control = cmsgbuf;
first = true;