On Sun, 13 Nov 2016 14:56:59 +0000, Jun Wu wrote: > Excerpts from Yuya Nishihara's message of 2016-11-13 23:18:10 +0900: > > On Fri, 11 Nov 2016 21:14:37 +0000, Jun Wu wrote: > > > # HG changeset patch > > > # User Jun Wu <qu...@fb.com> > > > # Date 1478898677 0 > > > # Fri Nov 11 21:11:17 2016 +0000 > > > # Node ID 4ccb6bcaf25a741d3a0d8abd6c674573ef76069a > > > # Parent 98761d64eaaf67f3bdb99f3f80a57910e2624b78 > > > # Available At https://bitbucket.org/quark-zju/hg-draft > > > # hg pull https://bitbucket.org/quark-zju/hg-draft -r > > > 4ccb6bcaf25a > > > osutil: implement setprocname to set process title for some platforms > > > > Seems fine. We can't guarantee argv[i] is null terminated for all i, but > > that seems less dangerous since the last argv[i] always has '\0'. > > You mean if some other code modifies "argv"? Seems fine - we may just think > the buffer is smaller.
I wanted to say there's no risk of OOB memory access even if some other codes do strsomething(argv[i]). They might see the data in argv[i + 1], which isn't desirable but not hazardous. So this patch looks good. > > > +#ifdef setprocname_method > > > +static PyObject *setprocname(PyObject *self, PyObject *args) > > > +{ > > > + const char *name = NULL; > > > + if (!PyArg_ParseTuple(args, "s", &name)) > > > + return NULL; > > > + > > > +#if 'a' == setprocname_method > > > + setproctitle("%s", name); > > > +#elif 'b' == setprocname_method > > > + static char *argvstart = NULL; > > > + static size_t argvsize = 0; > > > > Strictly speaking, these declarations should be moved to the block head. > > (But > > almost all modern compilers but for MSVC would allow mixed declarations.) > > Or we can put them in a "{}" scope - seems more readable. Yep. _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel