Skip to content

Commit

Permalink
Manual fix for conversion errors
Browse files Browse the repository at this point in the history
  • Loading branch information
john-h-kastner committed Oct 23, 2020
1 parent cfff1dc commit 7ed4cd5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion sysdeputil.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ int capset(cap_user_header_t header, const cap_user_data_t data)
#endif

#ifdef VSF_SYSDEP_TRY_LINUX_SETPROCTITLE_HACK
extern char** environ;
extern char ** environ;
static unsigned int s_proctitle_space = 0;
static int s_proctitle_inited = 0;
static char* s_p_proctitle = 0;
Expand Down Expand Up @@ -908,6 +908,12 @@ vsf_sysutil_setproctitle_init(int argc, const char* argv[])
{
int i;
char** p_env = environ;
/* Force p_env to stay wild */
if (0) {
*p_env = (char*) 0xBAD;
p_env = (char**) 0xBAD;
}

This comment has been minimized.

Copy link
@mwhicks1

mwhicks1 Nov 11, 2020

Member

Why are you doing this?

This comment has been minimized.

Copy link
@john-h-kastner

john-h-kastner Nov 11, 2020

Author

Couldn't figure out the correct conversion, but 3c wanted to make it checked, so I did this to force it to be WILD. The other thing I could have done is use an _Assume_bounds_cast to get it to compile.

if (s_proctitle_inited)
{
bug("vsf_sysutil_setproctitle_init called twice");
Expand Down
6 changes: 3 additions & 3 deletions sysutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,7 @@ vsf_sysutil_statbuf_get_date(const struct vsf_sysutil_statbuf* p_statbuf,
{
p_date_format = "%b %d %Y";
}
retval = strftime(datebuf, sizeof(datebuf), p_date_format, p_tm);
retval = strftime(datebuf, sizeof(datebuf) - 1, p_date_format, p_tm);
datebuf[sizeof(datebuf)-1] = '\0';
if (retval == 0)
{
Expand All @@ -1407,7 +1407,7 @@ vsf_sysutil_statbuf_get_numeric_date(
{
p_tm = localtime(&p_stat->st_mtime);
}
retval = strftime(datebuf, sizeof(datebuf), "%Y%m%d%H%M%S", p_tm);
retval = strftime(datebuf, sizeof(datebuf) - 1, "%Y%m%d%H%M%S", p_tm);

This comment has been minimized.

Copy link
@mwhicks1

mwhicks1 Nov 11, 2020

Member

I imagine this relates to microsoft/checkedc-clang#935

This comment has been minimized.

Copy link
@john-h-kastner

john-h-kastner Nov 11, 2020

Author

Look like it. I was confused when I encountered this, but looking at this and your issue, I can see how this is probably CheckedC messing up the bounds.

if (retval == 0)
{
die("strftime");
Expand Down Expand Up @@ -2624,7 +2624,7 @@ vsf_sysutil_get_current_date(void)
int i = 0;
curr_time = vsf_sysutil_get_time_sec();
p_tm = localtime(&curr_time);
if (strftime(datebuf, sizeof(datebuf), "%a %b!%d %H:%M:%S %Y", p_tm) == 0)
if (strftime(datebuf, sizeof(datebuf) - 1, "%a %b!%d %H:%M:%S %Y", p_tm) == 0)
{
die("strftime");
}
Expand Down

0 comments on commit 7ed4cd5

Please sign in to comment.