r18299 - gnucash/trunk/src/app-utils - Fix index-out-of-range compilation error

Derek Atkins warlord at MIT.EDU
Mon Sep 7 10:25:48 EDT 2009


Phil,

As I said on -devel, there is no need to change the strncpy length,
only the length in the NUL setting..  In the worst case scenario you
will over-write the last byte twice.

-derek

Quoting Phil Longstaff <plongstaff at code.gnucash.org>:

> Author: plongstaff
> Date: 2009-09-07 10:16:20 -0400 (Mon, 07 Sep 2009)
> New Revision: 18299
> Trac: http://svn.gnucash.org/trac/changeset/18299
>
> Modified:
>   gnucash/trunk/src/app-utils/gnc-ui-util.c
> Log:
> Fix index-out-of-range compilation error
>
>
> Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
> ===================================================================
> --- gnucash/trunk/src/app-utils/gnc-ui-util.c	2009-09-06 18:42:43 UTC 
> (rev 18298)
> +++ gnucash/trunk/src/app-utils/gnc-ui-util.c	2009-09-07 14:16:20 UTC 
> (rev 18299)
> @@ -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';
>
>   return result;
> }
>
> _______________________________________________
> gnucash-changes mailing list
> gnucash-changes at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-changes
>



-- 
       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