On 14 February 2015 at 09:59, Paweł Dziepak <pdziepak@xxxxxxxxxxx> wrote: > 2015-02-13 21:52 GMT+01:00 Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>: >> >> On Sat, 14 Feb 2015 9:38 AM null <waddlesplash@xxxxxxxxx> wrote: >> >> hrev48801 adds 1 changeset to branch 'master' >> old head: 7657d1c82cf0879a941c6f3969e8c48681bc8dbf >> new head: 1a499ee138f5c44e423ab6a4bea3accffe4b1c5a >> overview: >> http://cgit.haiku-os.org/haiku/log/?qt=range&q=1a499ee138f5+%5E7657d1c82cf0 >> >> >> ---------------------------------------------------------------------------- >> >> 1a499ee138f5: Cortex: LoggingConsumer addon: fix crash on startup. >> >> Fixes #11855. >> >> [ Augustin Cavalier <waddlesplash@xxxxxxxxx> >> ] >> >> >> ---------------------------------------------------------------------------- >> >> Revision: hrev48801 >> Commit: 1a499ee138f5c44e423ab6a4bea3accffe4b1c5a >> URL: http://cgit.haiku-os.org/haiku/commit/?id=1a499ee138f5 >> Author: Augustin Cavalier <waddlesplash@xxxxxxxxx> >> Date: Fri Feb 13 20:35:32 2015 UTC >> >> Ticket: https://dev.haiku-os.org/ticket/11855 >> >> >> ---------------------------------------------------------------------------- >> >> 1 file changed, 3 insertions(+), 3 deletions(-) >> src/apps/cortex/addons/LoggingConsumer/LoggingConsumerAddOn.cpp | 6 +++--- >> >> >> ---------------------------------------------------------------------------- >> >> diff --git >> a/src/apps/cortex/addons/LoggingConsumer/LoggingConsumerAddOn.cpp >> b/src/apps/cortex/addons/LoggingConsumer/LoggingConsumerAddOn.cpp >> index e64a132..eba50ae 100644 >> --- a/src/apps/cortex/addons/LoggingConsumer/LoggingConsumerAddOn.cpp >> +++ b/src/apps/cortex/addons/LoggingConsumer/LoggingConsumerAddOn.cpp >> @@ -80,10 +80,10 @@ status_t LoggingConsumerAddOn::GetFlavorAt( >> >> flavor_info* pInfo = new flavor_info; >> pInfo->internal_id = n; >> - strcpy(pInfo->name, "LoggingConsumer"); >> - strcpy(pInfo->info, "An add-on version of the LoggingConsumer >> node.\n" >> + pInfo->name = (char*)"LoggingConsumer"; >> + pInfo->info = (char*)"An add-on version of the LoggingConsumer >> node.\n" >> "See the Be Developer Newsletter III.18: 5 May, 1999\n" >> - "adapted by Eric Moon (4 June, 1999)"); >> + "adapted by Eric Moon (4 June, 1999)"; >> pInfo->kinds = B_BUFFER_CONSUMER | B_CONTROLLABLE; >> pInfo->flavor_flags = 0; >> pInfo->possible_count = 0; >> >> >> This looks like it's shadowing a more serious issue. Copying a constant >> string definitely shouldn't be causing a crash. >> >> This just looks like a blind band-aid approach to dealing with the issue >> :( > > > flavor_info::name and flavor_info::info are just a pointers, so strcpy() was > just copying these strings to a random memory location. The question, > however, remains whether there is some code that frees these strings. If > yes, then strdup() seems to be the best choice here. If no, then this change > is generally correct, though it is very nasty to cast away const. > Oops, I missed the difference between strcpy/strdup =/ The casting away of const is what caught my eye...