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:
Rene Kita
2022-04-15 12:42:24 +02:00
parent d33a522936
commit 9eaf044c02
4 changed files with 18 additions and 13 deletions

6
ftp.c
View File

@@ -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);