mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
build: fix TagName overflow issues
The 'TagName' string is defined to be 40 characters in length, but in three places we write into it with a format of "(%.39s)". This can result in a string of up to 42 characters, the 39 character user string plus "()\0". This overflows TagName, as we see in the new complier warnings from gcc 7.2.1: iogen.c:1277:6: note: 'sprintf' output between 3 and 42 bytes into a destination of size 40 sprintf( TagName, "(%.39s)", optarg ); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix this by limiting the user string to 37 characters. Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com> Reviewed-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
+1
-1
@@ -3184,7 +3184,7 @@ char *opts;
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
sprintf( TagName, "(%.39s)", optarg );
|
||||
sprintf( TagName, "(%.37s)", optarg );
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
|
||||
Reference in New Issue
Block a user