--- a/contrib/chg/hgclient.c Tue Jan 10 09:32:27 2017 +0100
+++ b/contrib/chg/hgclient.c Wed Jan 11 23:39:24 2017 +0800
@@ -366,9 +366,11 @@
static void updateprocname(hgclient_t *hgc)
{
- size_t n = (size_t)snprintf(hgc->ctx.data, hgc->ctx.maxdatasize,
+ int r = snprintf(hgc->ctx.data, hgc->ctx.maxdatasize,
"chg[worker/%d]", (int)getpid());
- hgc->ctx.datasize = n;
+ if (r < 0 || (size_t)r >= hgc->ctx.maxdatasize)
+ abortmsg("insufficient buffer to write procname (r = %d)", r);
+ hgc->ctx.datasize = (size_t)r;
writeblockrequest(hgc, "setprocname");
}