-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #150 from bjjwwang/0807
Create ExtAPI_strcat 4 cases
- Loading branch information
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
extern void UNSAFE_BUFACCESS(void *buffer, int size); | ||
|
||
int main() { | ||
char buffer[10]; | ||
char *largeString = "worldworld"; | ||
strcpy(buffer, "Hello"); | ||
strcat(buffer, largeString); | ||
UNSAFE_BUFACCESS(buffer, 5 + 10 + 1); // Hello 5, worldworld 10, null terminator 1 | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
extern void UNSAFE_BUFACCESS(void *buffer, int size); | ||
int main() { | ||
char buffer[20] = ""; | ||
char *strings[] = {"Hello", "World", "This", "Is", "Too", "Long"}; | ||
int i; | ||
for (i = 0; i < 6; i++) { | ||
strcat(buffer, strings[i]); | ||
} | ||
UNSAFE_BUFACCESS(buffer, 23); | ||
printf("Buffer: %s\n", buffer); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
extern void UNSAFE_BUFACCESS(void *buffer, int size); | ||
|
||
int main() { | ||
char buffer[10] = "Hi"; | ||
char input[20]; | ||
printf("Enter a string: "); | ||
scanf("%19s", input); | ||
strcat(buffer, input); | ||
UNSAFE_BUFACCESS(buffer, strlen(buffer)); | ||
printf("Buffer: %s\n", buffer); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
extern void UNSAFE_BUFACCESS(void *buffer, int size); | ||
int main() { | ||
char buffer[15] = "Start"; | ||
char *string1 = "12345"; | ||
char *string2 = "67890"; | ||
strcat(buffer, string1); | ||
strcat(buffer, string2); | ||
UNSAFE_BUFACCESS(buffer, 5 + strlen(string1) + strlen(string2)); | ||
printf("Buffer: %s\n", buffer); | ||
return 0; | ||
} |