From 95193fa86a0b445c521ef709bbb9bfe13d02ddbd Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 30 Aug 2010 20:10:12 +0000 Subject: [PATCH] src/svf/svf_flex.l: Use memcpy() rather than strcpy() when we already know the length and we just want to dupe the string. git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1838 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 3 +++ urjtag/src/svf/svf_flex.l | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index 01b2ecff..ff27134f 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -11,6 +11,9 @@ * src/svf/svf_flex.l (fix_yylloc): Accept the string length from caller to avoid useless overhead of calling strlen(). Fix by Frans Meulenbroeks. + * src/svf/svf_flex.l: Use memcpy() rather than strcpy() when we already know + the length and we just want to dupe the string. + 2010-08-26 Mike Frysinger * src/tap/cable/gpio.c: Rewrite to use raw file descriptors when working with diff --git a/urjtag/src/svf/svf_flex.l b/urjtag/src/svf/svf_flex.l index bc0f2e20..579d4181 100644 --- a/urjtag/src/svf/svf_flex.l +++ b/urjtag/src/svf/svf_flex.l @@ -149,7 +149,7 @@ COMMENT (!.*)|("//".*)[^\n] len = align_string(yytext); cstring = malloc(len + 1); - strcpy(cstring, yytext); + memcpy(cstring, yytext, len + 1); yylval->cvalue = cstring; return(VECTOR_STRING); } /* end of vector string */ @@ -172,7 +172,7 @@ COMMENT (!.*)|("//".*)[^\n] len = align_string(yytext); cstring = (char *)malloc(len + 1); - strcpy(cstring, yytext); + memcpy(cstring, yytext, len + 1); yylval->cvalue = cstring; return(HEXA_NUM_FRAGMENT); } /* end of hexadecimal value */