This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
- From: Ilya Verbin <iverbin at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Thomas Schwinge <thomas at codesourcery dot com>, Kirill Yukhin <kirill dot yukhin at gmail dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 28 Jan 2015 19:20:30 +0300
- Subject: Re: [PATCH 4/4] OpenMP 4.0 offloading to Intel MIC: non-fallback testing
- Authentication-results: sourceware.org; auth=none
- References: <20141021171323 dot GA47586 at msticlxl57 dot ims dot intel dot com> <20141030114001 dot GA34120 at msticlxl57 dot ims dot intel dot com> <87tx0t0yh5 dot fsf at kepler dot schwinge dot homeip dot net> <CADG=Z0GWtqLOLNdv3YbP-6jfagd68TKrXSjn27nrwi6YPQkFuQ at mail dot gmail dot com> <87oaqvzz0n dot fsf at kepler dot schwinge dot homeip dot net> <20141222123553 dot GK1667 at tucnak dot redhat dot com> <20150115185540 dot GD5706 at msticlxl57 dot ims dot intel dot com> <20150115185846 dot GJ1405 at tucnak dot redhat dot com> <20150128160259 dot GA12176 at msticlxl57 dot ims dot intel dot com> <20150128161525 dot GV1746 at tucnak dot redhat dot com>
On 28 Jan 17:15, Jakub Jelinek wrote:
> On Wed, Jan 28, 2015 at 07:02:59PM +0300, Ilya Verbin wrote:
> > + = XNEWVEC (char, len + sizeof ("-B" "../" DEFAULT_TARGET_MACHINE
> > + "/libgomp/"));
> > + sprintf (optional_target_path2, "-B%s/../../../" DEFAULT_TARGET_MACHINE
> > + "/libgomp/", current_path);
>
> This will surely overflow the buffer, won't it? There is space just for
> "../" but you put there "/../../../".
>
> I'd strongly prefer if you rewrote all these XNEWVEC or XRESIZEVEC etc.
> + sprintf cases into concat, like
> optional_target_path2 = concat ("-B", current_path,
> "/../../../" DEFAULT_TARGET_MACHINE
> "/libgomp/", NULL);
> and similar. That way you avoid all such bugs.
The variable 'len' contains sizeof ("/../../").
I agree that this code looks ugly :) I'll rewrite it using concat.
-- Ilya