File: 05_control_empty_values

package info (click to toggle)
chntpw 140201-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,100 kB
  • sloc: ansic: 23,909; makefile: 137
file content (40 lines) | stat: -rw-r--r-- 1,194 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
--- a/ntreg.c
+++ b/ntreg.c
@@ -2667,21 +2667,23 @@
 	      value = (char *)get_val_data(hdesc, nkofs, vex.name, vex.type, TPF_VK_EXACT);
 	      len = get_val_len(hdesc, nkofs, vex.name, TPF_VK_EXACT);
 
-	      if (vex.type == REG_BINARY) {
-		fprintf(file, "\"%s\"=hex:", vex.name);
-	      } else {
-		fprintf(file, "\"%s\"=hex(%x):", vex.name, vex.type);
-	      }
-	      byte = 0;
-	      while (byte < len) { /* go byte by byte.. probably slow.. */
-		fprintf(file, "%02x,", (unsigned char)value[byte]);
-		byte++;
-		if (!(byte % 20)) fprintf(file, "\\\r\n  ");
-	      }
-	      fprintf(file, "%02x\r\n", (unsigned char)value[byte]);
-            }
+	      if (value && len >= 0) {
+		if (vex.type == REG_BINARY) {
+		  fprintf(file, "\"%s\"=hex:", vex.name);
+		} else {
+		  fprintf(file, "\"%s\"=hex(%x):", vex.name, vex.type);
+		}
+		byte = 0;
+		while (byte < len) { /* go byte by byte.. probably slow.. */
+		  fprintf(file, "%02x,", (unsigned char)value[byte]);
+		  byte++;
+		  if (!(byte % 20)) fprintf(file, "\\\r\n  ");
+		}
+		fprintf(file, "%02x\r\n", (unsigned char)value[byte]);
 
-            FREE(vex.name);
+		FREE(vex.name);
+	      }
+	    }
         }
     }