strcpy
Stelios Xanthakis
root at ppp-pat141.tee.gr
Wed Apr 26 14:26:25 EEST 2000
On Wed, 26 Apr 2000, Giorgos Keramidas wrote:
>
> Epeidi den egine arxikopoihsh tou pointer dest3 otan ton ekane dhlosi mesa
> stin main(), autos eixe mia tuxaia timi. Edeixne omws gia kali tou tuxi
> kapou mesa stin stoiba.. kai gi' auto den tou petaei core stin grammi:
>
> strcpy(dest3, source);
>
> alla tou petaei meta, otan prospathei na kanei free() kati, pou i
> malloc() den to ekane allocate pote. Tora, h erotisi einai bebaia, ti
> einai pio shmantiko gia kapoion pou grafei kati tetoio:
>
To oti persases to programma tou L.O.V.E apo gdb einai kati endiaferon
alla ta simperasmata sou den einai toso xrisima sti sigekrimeni periprosi.
Pou to kseroume oti to dest3 edixne sto stack segment?
Tha mporouse na doulepsei ke ean edixne sto data segment.
I ``stoiba'' den einai to pan.
To pou tha dixnei i arxiki timi tou dest3 einai tyxaio ke
implementation/architecture/compiler dependent.
Den vlepo kapio logo na doume apo gdb pou egine to fault.
> a) oti etsi ki allios kai free() na min kanei, exei gamisei to stack
> tou, kai anamfibola prepei na timorh8ei me kana duo core dumps, se
> asxetes stigmes?
>
> b) oti kanei free() kati pou etsi ki allios den egine allocate, ara
> mallon to core dump to exei toso sigouro pou, who cares?
>
> c) oti exo mia entuposi pos diabases to posting mou, alla dustuxos den
> katalabes pou to phgaina.
>
> Pros apofugh tou (c) tis epomenes fores tha stelno kai disassembly tou
> programmatos apo to gdb(1), me commented ta shmeia pou to .c source exei
> kanei kati palabo. H monh pagida stin olh ypothesi einai oti kapoia
> stigmi, otan mazeutoun polla, ego bariemai na ta kano biblio, opote mallon
> tha balo esena na ta stoixeio8ethseis :)))
>
No thanks.
To thema den einai ti leo ego, alla ean o L.O.V.E tha mporei na
xrisimopoiisei aftes tis plirofories, ean pragmatika ton endiaferoun ke
poso tha gemisi i lista me asxeta mail.
O skopos tou arxikou mail itan na min giriso meta to pasxa ke vro 100 mail
me subject "Re:strcpy" (ke merika "strcpy" sketo:) pou tha exoume
exandlisei oles tis dinates sizitiseis pano sto thema (p.x. andi gia
strlen() kane sizeof. klp klp).
Eftixismenos o kainourgios Pasxas
Filika
Stelios
--
linux-greek-users mailing list -- http://lists.hellug.gr
More information about the Linux-greek-users
mailing list