[PATCH] Reserve enough memory when storing a DC's nickname

Dirk Hohndel dirk at hohndel.org
Sat Dec 15 21:54:15 PST 2012


"Lubomir I. Ivanov" <neolit123 at gmail.com> writes:

> On 15 December 2012 17:53, Dirk Hohndel <dirk at hohndel.org> wrote:
>> Sorry, just a quick email from my phone; on my way to the morning dives.
>> The function cleanedup_nickname was supposed to correctly shorten the string
>> if necessary to fit in the number of bytes allocated. Doesn't it do that
>> (and why?)
>>
>
> actually it seems to be working, i.e. remember_dc() does receive a
> reduced string.
>
> but what i've said before about the size of the "nickname" buffer in
> set_dc_nickname() previosly was correct.
> it has to be twice the size of the max allowed characters in:
> gtk_entry_set_max_length(GTK_ENTRY(entry), 68);
>
> otherwise this call in there:
> dive->dc.nickname =
> cleanedup_nickname(gtk_entry_get_text(GTK_ENTRY(entry)),
> sizeof(nickname));
> will always discard user entered characters at the end.
>
> i would simply increase both stack buffers to 256 in set_dc_nickname()
> and remember_dc() and this should make it always have space for the
> user entered unicode string, given that gtk_entry_set_max_length()
> sets the limit.
>

That makes sense. Pushed your change with an adjusted commit message

/D


More information about the subsurface mailing list