Check return value of Str... functions
All these functions, StrmyUFgets, StrISgets, etc. can potentially return NULL. Add a check for it.
This commit is contained in:
6
ftp.c
6
ftp.c
@@ -70,7 +70,8 @@ ftp_command(FTP ftp, char *cmd, char *arg, int *status)
|
||||
if (!status)
|
||||
return NULL;
|
||||
*status = -1; /* error */
|
||||
tmp = StrISgets(ftp->rf);
|
||||
if (!(tmp = StrISgets(ftp->rf)))
|
||||
return NULL;
|
||||
if (IS_DIGIT(tmp->ptr[0]) && IS_DIGIT(tmp->ptr[1]) &&
|
||||
IS_DIGIT(tmp->ptr[2]) && tmp->ptr[3] == ' ')
|
||||
sscanf(tmp->ptr, "%d", status);
|
||||
@@ -87,7 +88,8 @@ ftp_command(FTP ftp, char *cmd, char *arg, int *status)
|
||||
* with the same code, followed immediately by Space <SP>,
|
||||
* optionally some text, and the Telnet end-of-line code. */
|
||||
while (1) {
|
||||
tmp = StrISgets(ftp->rf);
|
||||
if (!(tmp = StrISgets(ftp->rf)))
|
||||
break;
|
||||
if (IS_DIGIT(tmp->ptr[0]) && IS_DIGIT(tmp->ptr[1]) &&
|
||||
IS_DIGIT(tmp->ptr[2]) && tmp->ptr[3] == ' ') {
|
||||
sscanf(tmp->ptr, "%d", status);
|
||||
|
Reference in New Issue
Block a user