# HG changeset patch # User Augie Fackler # Date 2016-03-20 00:02:19 # Node ID e60c492a0d9b00f9177a220cf3b812701b9f9af1 # Parent cdbd9c0c077508598bae9c43ac793356270ac723 osutil: stop using strcpy strcpy is a security vulnerability masquerading as a utility function. Replace it with memcpy since we know how much to copy anyway. diff --git a/mercurial/osutil.c b/mercurial/osutil.c --- a/mercurial/osutil.c +++ b/mercurial/osutil.c @@ -203,14 +203,15 @@ static PyObject *_listdir(char *path, in PyErr_NoMemory(); goto error_nomem; } - strcpy(pattern, path); + memcpy(pattern, path, plen); if (plen > 0) { char c = path[plen-1]; if (c != ':' && c != '/' && c != '\\') pattern[plen++] = '\\'; } - strcpy(pattern + plen, "*"); + pattern[plen++] = '*'; + pattern[plen] = '\0'; fh = FindFirstFileA(pattern, &fd); if (fh == INVALID_HANDLE_VALUE) {