adding validated services? patching forcad_local.py
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void) {
|
||||
// Build a format string at runtime in a local buffer
|
||||
char fmt[64];
|
||||
strcpy(fmt, "X:%.*s Y:%*d Z:%s W:%s END\n");
|
||||
|
||||
char s_local[32];
|
||||
for (int i = 0; i < (int)sizeof s_local; ++i) s_local[i] = (char)('0' + (i % 10));
|
||||
s_local[31] = '\0';
|
||||
|
||||
const char *g = "GLOB";
|
||||
int p = 5, w = 3;
|
||||
printf(fmt, p, "abcdefghijk", w, 9, g, s_local + 7);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
// Many arguments across a single printf to stress call shim
|
||||
// Avoid %p to keep outputs comparable across obfuscated/non-obfuscated runs.
|
||||
printf("M:%d %d %d %d %d %d %d %d %d %d %d %d | %s %s %s | %.*s %*d\n",
|
||||
1,2,3,4,5,6,7,8,9,10,11,12,
|
||||
"aa","bb","cc",
|
||||
3, "abcdefgh", 5, 777);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static const char g_fmt[] = "start:%s mid:%*d end:%s done\n";
|
||||
static const char g_hello[] = "HELLO";
|
||||
|
||||
int main(void) {
|
||||
char local[32];
|
||||
for (int i = 0; i < (int)sizeof local; ++i) local[i] = (char)('A' + (i % 26));
|
||||
local[31] = '\0';
|
||||
|
||||
const char *s1 = g_hello;
|
||||
const char *s2 = local + 5; // pointer into local buffer
|
||||
int width = 7;
|
||||
|
||||
// printf with global-encrypted fmt and both global/local string args
|
||||
printf(g_fmt, s1, width, 42, s2);
|
||||
|
||||
// more mixed specifiers including width/precision stars with strings
|
||||
const char *s3 = "abcdefg";
|
||||
int prec = 3;
|
||||
int w2 = 6;
|
||||
printf("mix:%.*s|%*d|%s|%s|%%\n", prec, s3, w2, -12345, s1, s2);
|
||||
|
||||
// Check %s with NULL and empty string
|
||||
const char *nulls = NULL;
|
||||
const char *emptys = "";
|
||||
printf("null:%s empty:%s end\n", nulls, emptys);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static const char g_tag[] = "XYZ";
|
||||
|
||||
int main(void) {
|
||||
char buf[256];
|
||||
char local[64];
|
||||
for (int i = 0; i < (int)sizeof local; ++i) local[i] = (char)('a' + (i % 26));
|
||||
local[63] = '\0';
|
||||
|
||||
// snprintf with dynamic width and precision, and local/global %s
|
||||
int w = 8, p = 4;
|
||||
int n = snprintf(buf, sizeof(buf), "A:%*d B:%.*s C:%s D:%s END", w, 321, p, "qwerty", g_tag, local + 2);
|
||||
printf("snlen=%d buf='%s'\n", n, buf);
|
||||
|
||||
// fprintf to a file
|
||||
FILE *f = fopen("tests_out_file.txt", "w");
|
||||
if (!f) {
|
||||
perror("fopen");
|
||||
return 1;
|
||||
}
|
||||
fprintf(f, "FILE:%s|%.*s|%d|%s\n", g_tag, 5, "ZYXWVUT", -77, local + 10);
|
||||
fclose(f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user