Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing error checks about function time(), gmtime() and strftime() #274

Open
lc3412 opened this issue Jul 17, 2020 · 2 comments
Open

Missing error checks about function time(), gmtime() and strftime() #274

lc3412 opened this issue Jul 17, 2020 · 2 comments

Comments

@lc3412
Copy link

lc3412 commented Jul 17, 2020

Hi,

I notice that funtion time(), gmtime() and strftime() are frequently used in the log.c. Here is an example of the usages, as shown in the following code, function time(), gmtime() and strftime() are do the handling actions when errors occur. So I think error handling towards these functions might be preferred.

sslsplit/log.c

Lines 634 to 650 in 9bac829

if (time(&epoch) == -1) {
log_err_printf("Failed to get time\n");
goto errout;
}
if ((utc = gmtime(&epoch)) == NULL) {
log_err_printf("Failed to convert time:"
" %s (%i)\n",
strerror(errno), errno);
goto errout;
}
if (!strftime(timebuf, sizeof(timebuf),
"%Y%m%dT%H%M%SZ", utc)) {
log_err_printf("Failed to format time:"
" %s (%i)\n",
strerror(errno), errno);
goto errout;
}

==============================================================================

However, in the other call sites of the same file, there exists several missing checks of function time(), gmtime() or strftime(). For example, as shown in the following code:

sslsplit/log.c

Lines 563 to 565 in 9bac829

time(&epoch);
utc = gmtime(&epoch);
strftime(timebuf, sizeof(timebuf), iso8601, utc);

@sonertari
Copy link
Collaborator

Yes, you can find such cases where we don't check the return values of system calls. Perhaps we should check them too.

@lc3412
Copy link
Author

lc3412 commented Aug 4, 2020

Thank you very much for your patience in responding me about the Error Handling Proposals. As you said, other cases about missing error code checks are also found. However, sometimes it is confusing to figure out whether such cases are necessary to be repaired. Especially, as shown above, in the same project, some cases are handled properly but others are not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants