nsmcp::accessScanInflate

 nsmcp::accessScanInflate

Defined in

Partial Call Graph (max 5 caller/called nodes):
accessFileScan accessFileScan nsmcp::accessScanInflate nsmcp::accessScanInflate accessFileScan->nsmcp::accessScanInflate instproc instproc instproc->nsmcp::accessScanInflate nsmcp::LogCorrelation nsmcp::LogCorrelation nsmcp::LogCorrelation->nsmcp::accessScanInflate

Testcases:
No testcase defined.
Source code:
    if {[dict get $file size]>$limit} {
        return -code error -errorcode {NSMCP ACCESS LIMIT compressed-bytes} "compressed access-log size limit exceeded"
    }
    set in [open [dict get $file path] rb]
    set out {}
    set ok false
    try {
        set out [file tempfile spool [file join $directory access-summary-]]
        fconfigure $out -translation binary
        set size 0
        set published [clock milliseconds]
        if {$progress ne ""} {
            uplevel #0 [list {*}$progress 0 {}]
        }
        set deadline [expr {[clock milliseconds]+15000}]
        while {1} {
            set memberStart [tell $in]
            zlib push gunzip $in
            set memberSize 0
            while {![eof $in]} {
                if {[clock milliseconds]>$deadline} {
                    return -code error -errorcode {NSMCP ACCESS LIMIT gzip-time} "gzip snapshot time limit exceeded"
                }
                set block [read $in [expr {min(65536,$limit-$size+1)}]]
                incr size [string length $block]
                incr memberSize [string length $block]
                if {$size>$limit} {
                    return -code error -errorcode {NSMCP ACCESS LIMIT decoded-bytes} "decoded access-log size limit exceeded"
                }
                puts -nonewline $out $block
                set now [clock milliseconds]
                if {$progress ne "" && $now-$published >= $heartbeat} {
                    uplevel #0 [list {*}$progress $size {}]
                    set published $now
                }
            }
            set checksum [fconfigure $in -checksum]
            chan pop $in
            set end [tell $in]
            # Tcl's transform can accept a truncated trailer at EOF. Verify its
            # CRC and ISIZE explicitly, before trusting the decompressed snapshot.
            if {$end-$memberStart<18} {
                error "incomplete gzip member"
            }
            seek $in [expr {$end-8}]
            set footer [read $in 8]
            binary scan $footer iu crc
            binary scan [string range $footer 4 7] iu length
            if {$crc!=$checksum || $length!=($memberSize & 0xffffffff)} {
                error "invalid gzip trailer"
            }
            seek $in $end
            set magic [read $in 2]
            if {$magic eq ""} {
                break
            }
            if {$magic ne "\x1f\x8b"} {
                error "unexpected data after gzip member"
            }
            seek $in $end
        }
        if {$progress ne ""} {
            uplevel #0 [list {*}$progress $size {}]
        }
        close $out
        set out {}
        set ok true
    } finally {
        catch {
            close $in
        }
        if {$out ne ""} {
            catch {
                close $out
            }
        }
        if {!$ok && [info exists spool]} {
            file delete -- $spool
        }
    }
    dict set file spool $spool
    dict set file decodedSize $size
    return $file
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: