Skip to content

Commit 9c59a69

Browse files
committed
Buffer overflow vulnerability fix
1 parent c0d5b37 commit 9c59a69

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/v-check-user-password.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,16 @@ int main (int argc, char** argv) {
4545
/* open log file */
4646
FILE* pFile = fopen ("/usr/local/vesta/log/auth.log","a+");
4747
if (NULL == pFile) {
48-
printf("Error: can not open file %s \n", argv[0]);
48+
printf("Error: can not open file /usr/local/vesta/log/auth.log \n");
4949
exit(12);
5050
}
5151

52+
int len = 0;
53+
if(strlen(argv[1]) >= 100) {
54+
printf("Too long username\n");
55+
exit(1);
56+
}
57+
5258
/* parse user argument */
5359
struct passwd* userinfo = getpwnam(argv[1]);
5460
if (NULL != userinfo) {

0 commit comments

Comments
 (0)