diff options
| author | Lutz Donnerhacke <donner@FreeBSD.org> | 2021-02-07 21:07:34 +0000 |
|---|---|---|
| committer | Lutz Donnerhacke <donner@FreeBSD.org> | 2021-05-09 13:23:19 +0000 |
| commit | e1caa707fee06d00a0e6ba0445d734e748721d77 (patch) | |
| tree | 58fc94b3f147b616fc8bcaed51c735d7fbaf636c /sys/netgraph | |
| parent | b1902474a7c51e025d734e8233f0e850291b92e7 (diff) | |
Diffstat (limited to 'sys/netgraph')
| -rw-r--r-- | sys/netgraph/ng_base.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index 271397f669be..4c6a2f606119 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -2771,7 +2771,7 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook) case NGM_BINARY2ASCII: { - int bufSize = 20 * 1024; /* XXX hard coded constant */ + int bufSize = 1024; const struct ng_parse_type *argstype; const struct ng_cmdlist *c; struct ng_mesg *binary, *ascii; @@ -2785,7 +2785,7 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook) error = EINVAL; break; } - +retry_b2a: /* Get a response message with lots of room */ NG_MKRESPONSE(resp, msg, sizeof(*ascii) + bufSize, M_NOWAIT); if (resp == NULL) { @@ -2827,9 +2827,13 @@ ng_generic_msg(node_p here, item_p item, hook_p lasthook) if (argstype == NULL) { *ascii->data = '\0'; } else { - if ((error = ng_unparse(argstype, - (u_char *)binary->data, - ascii->data, bufSize)) != 0) { + error = ng_unparse(argstype, (u_char *)binary->data, + ascii->data, bufSize); + if (error == ERANGE) { + NG_FREE_MSG(resp); + bufSize *= 2; + goto retry_b2a; + } else if (error) { NG_FREE_MSG(resp); break; } |
