summaryrefslogtreecommitdiffstats
path: root/misc/bdfresize/check_factor_args.diff
diff options
context:
space:
mode:
Diffstat (limited to 'misc/bdfresize/check_factor_args.diff')
-rw-r--r--misc/bdfresize/check_factor_args.diff48
1 files changed, 48 insertions, 0 deletions
diff --git a/misc/bdfresize/check_factor_args.diff b/misc/bdfresize/check_factor_args.diff
new file mode 100644
index 0000000000..5b9ad32e2c
--- /dev/null
+++ b/misc/bdfresize/check_factor_args.diff
@@ -0,0 +1,48 @@
+diff -Naur bdfresize-1.5/bdfresize.c bdfresize-1.5.patched/bdfresize.c
+--- bdfresize-1.5/bdfresize.c 2001-01-16 07:11:11.000000000 -0500
++++ bdfresize-1.5.patched/bdfresize.c 2021-09-10 14:39:09.553534254 -0400
+@@ -48,6 +48,22 @@
+
+ static int line;
+
++static int factor_is_bad(const char *p) {
++ int slashes = 0;
++ while(*p) {
++ if(*p == '/') {
++ if(++slashes > 1)
++ return 1;
++ } else if(*p >= '0' && *p <= '9') {
++ /* NOP */
++ } else {
++ return 1;
++ }
++ p++;
++ }
++ return 0;
++}
++
+ int
+ main(int argc, char *argv[])
+ {
+@@ -64,18 +80,21 @@
+ if (blackness <= 0) err ++;
+ break;
+ case 'w':
++ err += factor_is_bad(optarg);
+ numerator_x = atoi(optarg);
+ denominator_x = strchr(optarg,'/')
+ ? atoi(strchr(optarg,'/')+1) : 1;
+ if (numerator_x <= 0 || denominator_x <= 0) err ++;
+ break;
+ case 'h':
++ err += factor_is_bad(optarg);
+ numerator_y = atoi(optarg);
+ denominator_y = strchr(optarg,'/')
+ ? atoi(strchr(optarg,'/')+1) : 1;
+ if (numerator_y <= 0 || denominator_y <= 0) err ++;
+ break;
+ case 'f':
++ err += factor_is_bad(optarg);
+ numerator_x = numerator_y = atoi(optarg);
+ denominator_x = denominator_y = strchr(optarg,'/')
+ ? atoi(strchr(optarg,'/')+1) : 1;