Re: OFFTOPIC: core dumped with strcpy,atoi,sprintf.

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Ing(dot)Edmundo(dot)Robles(dot)Lopez" <erobles(at)sensacd(dot)com(dot)mx>, pgsql-general(at)postgresql(dot)org
Subject: Re: OFFTOPIC: core dumped with strcpy,atoi,sprintf.
Date: 2012-09-14 17:20:05
Message-ID: CAOR=d=2HwApuy4WzjNd3EVkG=fbhSDkWaL-qwRxrcFPGSVQMzg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Sep 14, 2012 at 10:37 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Ing.Edmundo.Robles.Lopez" <erobles(at)sensacd(dot)com(dot)mx> writes:
>> Debugging the program, found that the core is generated by atoi,
>> sprintf and similar functions; because that functions fails when
>> received a null pointer (NULL). But, if the functions received an
>> empty string ("") the program continues and run succesfully.
>
>> Yes, I should validate each input pointers. But, its odd that works in
>> SCO and not in Linux, and its odder that fails in functions like strcpy,
>> atoi, sprintf, etc.
>
> Not really. Per the POSIX spec, the behavior of those functions is
> undefined for NULL input pointers. Some platforms are forgiving about
> it, most are not.

I learned C on a platform with no memory protection wherein a null
pointer would result in a write to location 0 and an immediate machine
crash. Wow, that was a LONG time ago (late 80s). Kids today. Got it
easy.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Paul Jungwirth 2012-09-14 18:53:07 See the WHERE clause of a partial index
Previous Message jam3 2012-09-14 17:06:19 Re: Would my postgresql 8.4.12 profit from doubling RAM?