Browse Source
misc/bdfresize: Add argument checking.
misc/bdfresize: Add argument checking.
Signed-off-by: B. Watson <yalhcru@gmail.com> Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>pull/140/head
committed by
Willy Sudiarto Raharjo
No known key found for this signature in database
GPG Key ID: 3F617144D7238786
2 changed files with 66 additions and 9 deletions
@ -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; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue