Ticket Change Details
Overview

Artifact ID: 5f15c8b012fab61b89d408ce4ef805cf891e7afa
Ticket: bd6188edd4290bfdcff4a8ef9355f5280496eda5
dir2c: Output data as character array and not as string
User & Date: anonymous on 2020-05-11 16:38:04
Changes

  1. Change icomment to:

    Dear Roy,

    sorry, this patch also has an issue. The obfuscated version does not work any more (wrong variable data instead data_in).

    Here is a corrected total patch including ticket [127ac40147]

    
    --- C:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c.tcl	Mon May 11 07:31:09 2020
    +++ C:/oehhar/elmicron/projekte/el1005_scanlink_dll/source/c-vfs/dir2c_ori.tcl	Wed Jan 22 20:53:52 2020
    @@ -70,7 +70,7 @@
     
     		append ret "\\x${char}"
     
    -		if {(($idx+1) % 20) == 0} {
    +		if {($idx % 20) == 0 && $idx != 0} {
     			append ret "\"\n\""
     		}
     	}
    @@ -82,24 +82,6 @@
     	return $ret
     }
     
    -# Convert data to a character array
    -proc character_array {data} {
    -	set ret "\{\n\t"
    -	for {set idx 0} {$idx < [string length $data]} {incr idx} {
    -		binary scan [string index $data $idx] H* char
    -		append ret "0x${char}, "
    -
    -		if {(($idx+1) % 16) == 0 } {
    -			append ret "\n\t"
    -		}
    -	}
    -	set ret [string trimright $ret "\n, \t"]
    -
    -	append ret "\n\}"
    -
    -	return $ret
    -}
    -
     # Encrypt the data
     proc random_byte {} {
     	set value [expr {int(256 * rand())}]
    @@ -325,9 +307,16 @@
     #  endif /* !LOADED_CVFS_COMMON */}
     puts ""
     
    -# C struct data output buffer (must be delayed after definition of file data)
    -set struct_data ""
    -
    +puts "static struct cvfs_data ${code_tag}_data\[\] = {"
    +puts "\t{"
    +puts "\t\t/* Index 0 cannot be used because we use the value 0 to represent failure */"
    +puts "\t\t.name  = NULL,"
    +puts "\t\t.index = 0,"
    +puts "\t\t.type  = 0,"
    +puts "\t\t.size  = 0,"
    +puts "\t\t.data  = NULL,"
    +puts "\t\t.free  = 0,"
    +puts "\t},"
     for {set idx 1} {$idx < [llength $files]} {incr idx} {
     	set file [lindex $files $idx]
     	set shortfile [shorten_file $startdir $file]
    @@ -341,28 +330,15 @@
     
     			set fd [open $file]
     			fconfigure $fd -translation binary
    -			set data_in [read $fd]
    +			set data [read $fd]
     			close $fd
     
     			if {$obsfucate} {
     				set type "CVFS_FILETYPE_ENCRYPTED_FILE"
    -				set data_in [encrypt $data_in $obsfucation_key]
    +				set data "(unsigned char *) [stringify [encrypt $data $obsfucation_key]]"
     			} else {
     				set type "CVFS_FILETYPE_FILE"
    -			}
    -			# Microsoft VC9 compiler has a string limit of 65535 bytes
    -			# so put all larger files into an array which has a higher
    -			# string limit
    -			# For instance, the extra variable is used for all files.
    -			# this may be deactivated by removing "0 &" below
    -			if { 0 & $size <= 65535} {
    -				set data "(unsigned char *) [stringify $data_in]"
    -			} else {
    -				puts "/* Data of $shortfile */"
    -				set variable_name cvfs_data_$idx
    -				set data $variable_name
    -				puts "static unsigned char ${variable_name}\[\] =\
    -						[character_array $data_in];"
    +				set data "(unsigned char *) [stringify $data]"
     			}
     		}
     		"directory" {
    @@ -372,27 +348,15 @@
     		}
     	}
     
    -	append struct_data "\t{\n"\
    -			"\t\t/* name  */ \"$shortfile\",\n"\
    -			"\t\t/* index */ $idx,\n"\
    -			"\t\t/* size  */ $size,\n"\
    -			"\t\t/* type  */ $type,\n"\
    -			"\t\t/* data  */ $data,\n"\
    -			"\t\t/* free  */ 0,\n"\
    -			"\t},\n"
    +	puts "\t{"
    +	puts "\t\t.name  = \"$shortfile\","
    +	puts "\t\t.index = $idx,"
    +	puts "\t\t.type  = $type,"
    +	puts "\t\t.size  = $size,"
    +	puts "\t\t.data  = $data,"
    +	puts "\t\t.free  = 0,"
    +	puts "\t},"
     }
    -puts ""
    -puts "static struct cvfs_data ${code_tag}_data\[\] = {"
    -puts "\t{"
    -puts "\t\t/* Index 0 cannot be used because we use the value 0 to represent failure */"
    -puts "\t\t/* name  */ NULL,"
    -puts "\t\t/* index */ 0,"
    -puts "\t\t/* type  */ 0,"
    -puts "\t\t/* size  */ 0,"
    -puts "\t\t/* data  */ NULL,"
    -puts "\t\t/* free  */ 0,"
    -puts "\t},"
    -puts -nonewline $struct_data
     puts "};"
     puts ""
    
    
  2. Change login to "anonymous"
  3. Change mimetype to "text/x-fossil-wiki"
  4. Change priority to "Immediate"
  5. Change resolution to "Open"
  6. Change subsystem to "Tcl"
  7. Change username to "oehhar"