X-Git-Url: http://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=ncurses%2Ftinfo%2Fwrite_entry.c;h=e1baf9e2325dc7474cb64aebd2d1b2998002c922;hb=768f77851c2350c02252b8e0e5d69fc435940b83;hp=138517651e12646b3ec08984a57b3f608a8de594;hpb=47d2fb4537d9ad5bb14f4810561a327930ca4280;p=ncurses.git diff --git a/ncurses/tinfo/write_entry.c b/ncurses/tinfo/write_entry.c index 13851765..e1baf9e2 100644 --- a/ncurses/tinfo/write_entry.c +++ b/ncurses/tinfo/write_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2018-2021,2022 Thomas E. Dickey * * Copyright 1998-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -51,7 +51,7 @@ #define TRACE_NUM(n) /* nothing */ #endif -MODULE_ID("$Id: write_entry.c,v 1.115 2020/02/02 23:34:34 tom Exp $") +MODULE_ID("$Id: write_entry.c,v 1.120 2022/04/23 19:59:10 tom Exp $") static int total_written; static int total_parts; @@ -71,7 +71,7 @@ write_file(char *filename, TERMTYPE2 *tp) _nc_warning("entry is larger than %u bytes", limit); } else { FILE *fp = ((_nc_access(filename, W_OK) == 0) - ? fopen(filename, BIN_W) + ? safe_fopen(filename, BIN_W) : 0); size_t actual; @@ -145,7 +145,7 @@ make_db_path(char *dst, const char *src, size_t limit) rc = 0; } } else { - if (strlen(top) + strlen(src) + 2 <= limit) { + if ((strlen(top) + strlen(src) + 6) <= limit) { _nc_SPRINTF(dst, _nc_SLIMIT(limit) "%s/%s", top, src); rc = 0; } @@ -190,9 +190,9 @@ make_db_root(const char *path) #else struct stat statbuf; - if ((rc = stat(path, &statbuf)) < 0) { + if ((rc = stat(path, &statbuf)) == -1) { rc = mkdir(path -#if !defined(_WIN32) +#ifndef _NC_WINDOWS ,0777 #endif ); @@ -248,7 +248,7 @@ _nc_set_writedir(const char *dir) || getcwd(actual, sizeof(actual)) == 0) _nc_err_abort("%s: not a directory", destination); #endif - _nc_keep_tic_dir(strdup(actual)); + _nc_keep_tic_dir(actual); } /* @@ -442,7 +442,7 @@ _nc_write_entry(TERMTYPE2 *const tp) write_file(filename, tp); if (start_time == 0) { - if (stat(filename, &statbuf) < 0 + if (stat(filename, &statbuf) == -1 || (start_time = statbuf.st_mtime) == 0) { _nc_syserr_abort("error obtaining time from %s/%s", _nc_tic_dir(0), filename);