mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
Fix bug 6546: Avoid accessing buf[-1] if NUL byte comes from fgets
This commit is contained in:
parent
3b7f8a759f
commit
6aef5e591f
@ -118,7 +118,10 @@ static int DoWriteCommand( int argc, char **argv, bool debugflag, char *exename
|
||||
if (fgets( linein, sizeof( linein ) - 1, f1 ) == NULL) {
|
||||
break;
|
||||
}
|
||||
linein[strlen( linein ) - 1] = 0; /* whack the line delimiter */
|
||||
if ((strlen(linein) > 0)
|
||||
&& (linein[strlen(linein)-1] == '\n')) {
|
||||
linein[strlen(linein)-1] = 0;
|
||||
}
|
||||
|
||||
if ( debugflag )
|
||||
printf( "Read line [%s]\n", linein );
|
||||
|
@ -4262,8 +4262,9 @@ static bool get_user_tokens_from_file(FILE *f,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (line[strlen(line)-1] == '\n')
|
||||
if ((strlen(line) > 0) && (line[strlen(line)-1] == '\n')) {
|
||||
line[strlen(line)-1] = '\0';
|
||||
}
|
||||
|
||||
if (line[0] == ' ') {
|
||||
/* We have a SID */
|
||||
|
@ -94,7 +94,9 @@ static void get_auth_data(const char *srv, const char *shr, char *wg, int wglen,
|
||||
if (fgets(tmp, sizeof(tmp), stdin) == NULL) {
|
||||
return;
|
||||
}
|
||||
if(tmp[strlen(tmp)-1] == '\n')tmp[strlen(tmp)-1] = '\0';
|
||||
if ((strlen(tmp) > 0) && (tmp[strlen(tmp)-1] == '\n')) {
|
||||
tmp[strlen(tmp)-1] = '\0';
|
||||
}
|
||||
strncpy(un, tmp, unlen-1);
|
||||
} else if(username) strncpy(un, username, unlen-1);
|
||||
|
||||
|
@ -95,7 +95,9 @@ again:
|
||||
|
||||
nbench_line_count++;
|
||||
|
||||
line[strlen(line)-1] = 0;
|
||||
if ((strlen(line) > 0) && line[strlen(line)-1] == '\n') {
|
||||
line[strlen(line)-1] = 0;
|
||||
}
|
||||
|
||||
all_string_sub(line,"client1", cname, sizeof(line));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user