Compile error

Derek Atkins warlord at MIT.EDU
Mon Sep 7 10:04:51 EDT 2009


Hi,

Quoting Herbert Thoma <herbert.thoma at iis.fraunhofer.de>:

> Hi!
>
[snip]
> cc1: warnings being treated as errors
> gnc-ui-util.c: In function ‘gnc_account_get_full_name’:
> gnc-ui-util.c:760: error: array subscript is above array bounds
>
> The following patch fixes this problem:
>
> Index: src/app-utils/gnc-ui-util.c
> ===================================================================
> --- src/app-utils/gnc-ui-util.c (Revision 18298)
> +++ src/app-utils/gnc-ui-util.c (Arbeitskopie)
> @@ -756,8 +756,8 @@
>   if (!account) return NULL;
>
>   name = xaccAccountGetFullName (account);
> -  strncpy( result, name, sizeof(result)-1 );
> -  result[sizeof(result)] = '\0';
> +  strncpy( result, name, sizeof(result)-2 );
> +  result[sizeof(result)-1] = '\0';

Thank you for this patch.  Yes, this is definitely a bug.  However,
there is no need to change the strncpy, only the NUL setting.

>   return result;
> }
>
> Herbert

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available



More information about the gnucash-devel mailing list