[U-Boot] [PATCH v3] miiphy: use strncpy() not sprintf()

Wolfgang Denk wd at denx.de
Tue Jul 26 14:00:54 CEST 2011


Dear Laurence Withers,

In message <1310727678-30367-1-git-send-email-lwithers at guralp.com> you wrote:
> In miiphy_register() the new device's name was initialised by passing a
> string parameter as the format string to sprintf(). As this would cause
> problems if it ever contained a '%' symbol, switch to using strncpy()
> instead.
> 
> Signed-off-by: Laurence Withers <lwithers at guralp.com>
> Cc: Andy Fleming <afleming at freescale.com>
> ---
> Changes for v2:
>  - Use strncpy() rather than plain strcpy() for extra safety.
> 
> Changes for v3:
>  - Use BUG_ON() as an additional safety measure to ensure the name never
>    exceeds the buffer size MDIO_NAME_LEN, simplifying the previous test.
> ---
>  common/miiphyutil.c |   14 ++++----------
>  1 files changed, 4 insertions(+), 10 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Though a program be but three lines long,
someday it will have to be maintained."
- The Tao of Programming


More information about the U-Boot mailing list