[Freeciv-Dev] Re: (PR#3706) append the capstring
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Wed, Mar 12, 2003 at 08:43:27PM -0800, Jason Short wrote:
> Mike Kaufman wrote:
>
> The capstr.c code does not fit in to capability.c (any more than the
> savegame or tilespec capability code does). It could be moved into some
> network file, though.
hmm, ok, then we could rename this append_capstring();
> The problem is it truncates the capability [1]. This isn't likely to
> break anything (at least within our lifetimes), but it is unsafe.
>
> Either don't add anything to the capstring and return FALSE (this simply
> means checking the length before calling mystrlcat), or reallocate the
> capstring to be larger if necessary.
>
> bool append_capability(const char *str)
> {
> size_t len;
>
> len = strlen(our_capability_internal) + strlen(str) + strlen(" ");
> if (len >= MAX_LEN_CAPSTR) {
return FALSE;
}
>
> sz_strlcat(our_capability_internal, " ");
> len = mystrlcat(our_capability_internal, str, MAX_LEN_CAPSTR);
>
> assert(len < MAX_LEN_CAPSTR);
> return TRUE;
> }
this looks fine. so commit it. :)
-mike
- [Freeciv-Dev] (PR#3706) append the capstring, Mike Kaufman, 2003/03/12
- Message not available
- [Freeciv-Dev] Re: (PR#3706) append the capstring, Jason Short, 2003/03/12
- [Freeciv-Dev] Re: (PR#3706) append the capstring, Mike Kaufman, 2003/03/12
- [Freeciv-Dev] Re: (PR#3706) append the capstring, Jason Short, 2003/03/12
- [Freeciv-Dev] Re: (PR#3706) append the capstring,
Mike Kaufman <=
- [Freeciv-Dev] Re: (PR#3706) append the capstring, Jason Short, 2003/03/21
- [Freeciv-Dev] Re: (PR#3706) append the capstring, Mike Kaufman, 2003/03/21
- [Freeciv-Dev] Re: (PR#3706) append the capstring, Jason Short, 2003/03/21
|
|