[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] Parsing af param=value strenge med libc



Henrik Bork Steffensen wrote:
> hvordan parser jeg lettest POST data og HTTP_COOKIE strenge i c ved
> hjælp af libc eller lign.?
> Hvad gør i?

Har du spekuleret på at bruge perl eller lignende?

C's streng behandling og hukommelsesallokeringsbøvl er simpelthen en
sadistisk form for masochisme, specielt når det kommer til CGI scripts,
hvor der ikke burde være for mange bufferoverflows.

Et trick for at debugge CGI scripts er btw. at konfigurere apache så
den er ejet af din bruger og gruppe, indsætte en sleep(10) i starten
af CGI programmet, mens CGI scriptet venter kan du attache en debugger
til processen. F.eks. med noget i retning af

ddd `pidof script.cgi`



I perl ville jeg noget i retning af:

read(STDIN, $data, $ENV{'CONTENT_LENGTH'});
foreach $pair (split (/&/, $data))
{
   ($key, $value) = split (/=/, $pair);

   $value =~ s/\+/ /g;
   $key   =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack("C", hex ($1))/eg;
   $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack("C", hex ($1))/eg;

   $p{$key} = $value;
}

%p hash'en indeholder så key, value par.

For at fange en cookie ($reply er HTTP headere):
$cookie= ($reply =~ /Set-Cookie:\s*(.*)/i);

-- 
  Mvh. Carsten Svaneborg
http://www.softwarepatenter.dk


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *