free(ai);
}
- strncpy(tokbuf, prefix, sizeof(tokbuf)-1);
- tokbuf[sizeof(tokbuf) - 1] = 0;
+ strlcpy(tokbuf, prefix, sizeof(tokbuf));
tok = strtok_r(tokbuf, delim, &saveptr);
while (tok != NULL) {
if ((id = imagecache_get_id(icon))) {
snprintf(buf, sizeof(buf), "imagecache/%d", id);
} else {
- strncpy(buf, icon, sizeof(buf));
- buf[sizeof(buf)-1] = '\0';
+ strlcpy(buf, icon, sizeof(buf));
}
return buf;
di->provid = provid;
di->ecmtime = ecmtime;
di->hops = hops;
- strncpy(di->cardsystem, cardsystem, sizeof(di->cardsystem)-1);
- strncpy(di->reader, reader, sizeof(di->reader)-1);
- strncpy(di->from, from, sizeof(di->protocol)-1);
- strncpy(di->protocol, protocol, sizeof(di->protocol)-1);
+ strlcpy(di->cardsystem, cardsystem, sizeof(di->cardsystem));
+ strlcpy(di->reader, reader, sizeof(di->reader));
+ strlcpy(di->from, from, sizeof(di->protocol));
+ strlcpy(di->protocol, protocol, sizeof(di->protocol));
pthread_mutex_lock(&t->s_stream_mutex);
descrambler_notify_deliver(t, di);
if (tm >= 0)
snprintf(prop_sbuf, PROP_SBUF_LEN, "%02d:%02d", tm / 60, tm % 60);
else
- strncpy(prop_sbuf, N_("Any"), 16);
+ strlcpy(prop_sbuf, N_("Any"), PROP_SBUF_LEN);
return &prop_sbuf_ptr;
}
dvr_entry_class_status_get(void *o)
{
dvr_entry_t *de = (dvr_entry_t *)o;
- strncpy(prop_sbuf, dvr_entry_status(de), PROP_SBUF_LEN);
- prop_sbuf[PROP_SBUF_LEN-1] = '\0';
+ strlcpy(prop_sbuf, dvr_entry_status(de), PROP_SBUF_LEN);
return &prop_sbuf_ptr;
}
dvr_entry_class_sched_status_get(void *o)
{
dvr_entry_t *de = (dvr_entry_t *)o;
- strncpy(prop_sbuf, dvr_entry_schedstatus(de), PROP_SBUF_LEN);
- prop_sbuf[PROP_SBUF_LEN-1] = '\0';
+ strlcpy(prop_sbuf, dvr_entry_schedstatus(de), PROP_SBUF_LEN);
return &prop_sbuf_ptr;
}
} else if (s[0] && !isalpha(id[0])) {
snprintf(tmp, tmplen, "%c%s", id[0], s);
} else {
- strncpy(tmp, s, tmplen-1);
- tmp[tmplen-1] = '\0';
+ strlcpy(tmp, s, tmplen);
}
return dvr_clean_directory_separator(tmp, tmp, tmplen);
}
static const char *
dvr_sub_str_separator(const char *id, const char *fmt, const void *aux, char *tmp, size_t tmplen)
{
- strncpy(tmp, (const char *)aux, tmplen-1);
- tmp[tmplen-1] = '\0';
+ strlcpy(tmp, (const char *)aux, tmplen);
return dvr_clean_directory_separator(tmp, tmp, tmplen);
}
static const char *
dvr_sub_basename(const char *id, const char *fmt, const void *aux, char *tmp, size_t tmplen)
{
- strncpy(tmp, (const char *)aux, tmplen);
- tmp[tmplen-1] = '\0';
+ strlcpy(tmp, (const char *)aux, tmplen);
return basename(tmp);
}
localtime_r(&de->de_start, &tm);
- strncpy(path, cfg->dvr_storage, sizeof(path));
- path[sizeof(path)-1] = '\0';
+ strlcpy(path, cfg->dvr_storage, sizeof(path));
l = strlen(path);
if (l + 1 >= sizeof(path)) {
tvherror(LS_DVR, "wrong storage path");
if (dir_dosubs) {
htsstr_substitute(de->de_directory+2, ptmp, sizeof(ptmp), '$', dvr_subs_entry, de, tmp, sizeof(tmp));
} else {
- strncpy(ptmp, de->de_directory, sizeof(ptmp)-1);
- ptmp[sizeof(ptmp)-1] = '\0';
+ strlcpy(ptmp, de->de_directory, sizeof(ptmp));
}
s = ptmp;
while (*s == '/')
if (tm >= 0)
snprintf(prop_sbuf, PROP_SBUF_LEN, "%02d:%02d", tm / 60, tm % 60);
else
- strncpy(prop_sbuf, N_("Any"), 16);
+ strlcpy(prop_sbuf, N_("Any"), PROP_SBUF_LEN);
return &prop_sbuf_ptr;
}
return dvr_vfs_find(old, &fsid);
} else if ((s = htsmsg_get_str(m, "fsid0")) != NULL) {
fsid.fsid = 0;
- strncpy(fsid.id, s, sizeof(fsid.id)-1);
- fsid.id[sizeof(fsid.id)-1] = '\0';
+ strlcpy(fsid.id, s, sizeof(fsid.id));
return dvr_vfs_find(old, &fsid);
}
return NULL;
char buf[1024];
char *mid, *cid;
epggrab_module_t *mod;
- strncpy(buf, id, sizeof(buf));
- buf[sizeof(buf)-1] = '\0';
+ strlcpy(buf, id, sizeof(buf));
if ((mid = strtok_r(buf, "|", &cid)) && cid)
if ((mod = epggrab_module_find_by_id(mid)) != NULL)
return epggrab_channel_find(mod, cid, 0, NULL);
memset(&addr, 0, sizeof(struct sockaddr_un));
addr.sun_family = AF_UNIX;
- strncpy(addr.sun_path, mod->path, 100);
+ strlcpy(addr.sun_path, mod->path, sizeof(addr.sun_path));
if (bind(sock, (struct sockaddr*)&addr,
sizeof(struct sockaddr_un)) != 0) {
tvherror(mod->subsys, "%s: failed to bind socket: %s", mod->id, strerror(errno));
if (crid) {
if (strstr(buf, "crid://") == buf) {
- strncpy(crid, buf, clen);
- crid[clen-1] = '\0';
+ strlcpy(crid, buf, clen);
} else if (*buf != '/') {
snprintf(crid, clen, "crid://%s", buf);
} else {
if (langlist) {
htsmsg_field_t *item;
char langbuf[MAX_TEXT_LEN];
+ size_t l = 0;
langbuf[0] = '\0';
HTSMSG_FOREACH(item, langlist) {
s = htsmsg_field_get_str(item);
- if (s) {
- strncat(langbuf, s, sizeof(langbuf) - strlen(langbuf) - 1);
- strncat(langbuf, "|", sizeof(langbuf) - strlen(langbuf) - 1);
- }
+ if (s)
+ tvh_strlcatf(langbuf, MAX_TEXT_LEN, l, "%s|", s);
}
- if (strlen(langbuf) > 0)
+ if (l > 0)
return strdup(langbuf);
}
}
if (regex_match_substring(&p->compiled, matchno, matchbuf, sizeof(matchbuf)))
break;
size_t len = strlen(buf);
- strncat(buf, matchbuf, size_buf - len - 1);
+ strlcat(buf, matchbuf, size_buf - len);
}
rtrim(buf);
tvhtrace(LS_EPGGRAB," pattern \"%s\" matches '%s' from '%s'", p->text, buf, text);
if (p->filter) {
- strncpy(textbuf, buf, MAX_TEXT_LEN - 1);
- textbuf[MAX_TEXT_LEN - 1] = '\0';
+ strlcpy(textbuf, buf, MAX_TEXT_LEN);
text = textbuf;
continue;
}
memset(&tm, 0, sizeof(tm));
tm.tm_mday = 1; /* Day is one-based not zero-based */
- strncpy(str, in, sizeof(str));
- str[sizeof(str)-1] = '\0';
+ strlcpy(str, in, sizeof(str));
/* split tz */
while (str[sp] && str[sp] != ' ' && str[sp] != '+' && str[sp] != '-')
const size_t len = strlen(str);
if (len >= 4) {
char year_buf[32];
- strncpy(year_buf, str, 4);
- year_buf[5] = 0;
+ strlcpy(year_buf, str, 5);
const int64_t year = atoll(year_buf);
/* Sanity check the year before copying it over. */
if (year > 1800 && year < 2500) {
const char *s = v;
char n[4];
int save;
- strncpy(n, s && s[0] ? lang_code_get(s) : "", 4);
- n[3] = 0;
+ strlcpy(n, s && s[0] ? lang_code_get(s) : "", 4);
save = strcmp(esf->esf_language, n);
strcpy(esf->esf_language, n);
return save;
const char *s = v;
int save = 0;
if (strncmp(esf->esf_service, s, UUID_HEX_SIZE)) {
- strncpy(esf->esf_service, s, UUID_HEX_SIZE);
- esf->esf_service[UUID_HEX_SIZE-1] = '\0';
+ strlcpy(esf->esf_service, s, UUID_HEX_SIZE);
save = 1;
}
return save;
fb_dirent *ret = NULL;
if (dir->type == FB_BUNDLE) {
if (dir->b.cur) {
- strncpy(dir->dirent.name, dir->b.cur->name, sizeof(dir->dirent.name)-1);
- dir->dirent.name[sizeof(dir->dirent.name)-1] = '\0';
+ strlcpy(dir->dirent.name, dir->b.cur->name, sizeof(dir->dirent.name));
dir->dirent.type = dir->b.cur->type;
dir->b.cur = dir->b.cur->next;
ret = &dir->dirent;
i = 0;
while (fb) {
(*list)[i] = calloc(1, sizeof(fb_dirent));
- strncpy((*list)[i]->name, fb->name, sizeof((*list)[i]->name));
- (*list)[i]->name[sizeof((*list)[i]->name)-1] = '\0';
+ strlcpy((*list)[i]->name, fb->name, sizeof((*list)[i]->name));
fb = fb->next;
i++;
}
mono ^= 0xa1687211885fcd30LL;
snprintf(stamp, sizeof(stamp), "%"PRId64, mono);
m = md5sum(stamp, 1);
- strncpy(n->nonce, m, sizeof(stamp));
- n->nonce[sizeof(stamp)-1] = '\0';
+ strlcpy(n->nonce, m, sizeof(stamp));
pthread_mutex_lock(&global_lock);
if (RB_INSERT_SORTED(&http_nonces, n, link, http_nonce_cmp)) {
pthread_mutex_unlock(&global_lock);
if (nonce == NULL)
return 0;
- strncpy(tmp.nonce, nonce, sizeof(tmp.nonce)-1);
- tmp.nonce[sizeof(tmp.nonce)-1] = '\0';
+ strlcpy(tmp.nonce, nonce, sizeof(tmp.nonce));
pthread_mutex_lock(&global_lock);
n = RB_FIND(&http_nonces, &tmp, link, http_nonce_cmp);
if (n) {
if(!strcasecmp(ra->key, name)) {
TAILQ_REMOVE(list, ra, link);
empty = ra->val == NULL;
- if (!empty) {
- strncpy(buf, ra->val, sizeof(buf)-1);
- buf[sizeof(buf)-1] = '\0';
- }
+ if (!empty)
+ strlcpy(buf, ra->val, sizeof(buf));
free(ra->key);
free(ra->val);
free(ra);
return dst;
}
}
- strncpy(dst, idnode_uuid_as_str(in, ubuf), dstsize);
- dst[dstsize-1] = 0;
+ strlcpy(dst, idnode_uuid_as_str(in, ubuf), dstsize);
return dst;
}
if (!strncasecmp(i->url, "file://", 7)) {
fn = tvh_strdupa(i->url + 7);
http_deescape(fn);
- strncpy(name, fn, len);
- name[len-1] = '\0';
+ strlcpy(name, fn, len);
}
/* Remote file */
if (!fr) {
fr = calloc(1, sizeof(*fr));
fr->regionid = id;
- strncpy(fr->name, name, sizeof(fr->name)-1);
- fr->name[sizeof(fr->name)-1] = '\0';
+ strlcpy(fr->name, name, sizeof(fr->name));
TAILQ_INIT(&fr->services);
LIST_INSERT_HEAD(&bi->fregions, fr, link);
}
snprintf(buf, sizeof(buf), "Region %d", regionid);
str = buf;
}
- strncpy(fr->name, str, sizeof(fr->name)-1);
- fr->name[sizeof(fr->name)-1] = '\0';
+ strlcpy(fr->name, str, sizeof(fr->name));
TAILQ_INIT(&fr->services);
LIST_INSERT_HEAD(&bi->fregions, fr, link);
}
/* BAT */
} else if (tableid == 0x4A) {
tvhdebug(mt->mt_subsys, "%s: bouquet %04X (%d) [%s]", mt->mt_name, nbid, nbid, name);
- if (bi && *name) {
- strncpy(bi->name, name, sizeof(bi->name)-1);
- bi->name[sizeof(bi->name)-1] = '\0';
- }
+ if (bi && *name)
+ strlcpy(bi->name, name, sizeof(bi->name));
/* NIT */
} else {
#include <string.h>
#include <time.h>
#include "tvhlog.h"
+#include "tvh_string.h"
#include "en50221.h"
#include "input/mpegts/dvb.h"
#include "descrambler/caid.h"
!strncmp(im->mm_iptv_url, "file://", 7)))
return s;
p = url_encode(s);
- strncpy(tmp, p, tmplen-1);
- tmp[tmplen-1] = '\0';
+ strlcpy(tmp, p, tmplen);
free(p);
return tmp;
}
{
iptv_mux_t *im = (iptv_mux_t*)mm;
if(im->mm_iptv_muxname) {
- strncpy(buf, im->mm_iptv_muxname, len);
- buf[len-1] = '\0';
+ strlcpy(buf, im->mm_iptv_muxname, len);
} else if(im->mm_iptv_url_sane) {
- strncpy(buf, im->mm_iptv_url_sane, len);
- buf[len-1] = '\0';
- } else
+ strlcpy(buf, im->mm_iptv_url_sane, len);
+ } else {
*buf = 0;
+ }
}
/*
mpegts_input_display_name ( mpegts_input_t *mi, char *buf, size_t len )
{
if (mi->mi_name) {
- strncpy(buf, mi->mi_name, len - 1);
- buf[len - 1] = '\0';
- } else
+ strlcpy(buf, mi->mi_name, len);
+ } else {
*buf = 0;
+ }
}
int
mpegts_network_display_name
( mpegts_network_t *mn, char *buf, size_t len )
{
- strncpy(buf, tvh_str_default(mn->mn_network_name, "unknown"), len);
+ strlcpy(buf, tvh_str_default(mn->mn_network_name, "unknown"), len);
}
static bouquet_t *
fatal = 1;
continue;
} else {
- strncpy((char *)session, rtsp->hc_rtsp_session ?: "", sizeof(session));
- session[sizeof(session)-1] = '\0';
+ strlcpy((char *)session, rtsp->hc_rtsp_session ?: "", sizeof(session));
stream_id = rtsp->hc_rtsp_stream_id;
tvhdebug(LS_SATIP, "%s #%i - new session %s stream id %li",
rtsp->hc_host, lfe->sf_number,
int opos;
/* Region */
- strncpy(buf, name, sizeof(buf));
- buf[sizeof(buf)-1] = '\0';
+ strlcpy(buf, name, sizeof(buf));
if (!strcmp(type, "dvb-s")) {
reg = scanfile_region_create(type, "geo", "Geo-synchronous Orbit");
} else {
snprintf(buf, sizeof(buf), "%s%sTRANSLIT", charset, delim);
else if (ignore_bad_chars)
snprintf(buf, sizeof(buf), "%s%sIGNORE", charset, delim);
- else {
- strncpy(buf, charset, sizeof(buf));
- buf[sizeof(buf)-1] = '\0';
- }
+ else
+ strlcpy(buf, charset, sizeof(buf));
return buf;
}
ssize_t res;
if (dst_charset_id == NULL) {
- strncpy(dst, src_utf8, dst_size);
- dst[dst_size - 1] = '\0';
+ strlcpy(dst, src_utf8, dst_size);
return strlen(dst);
}
templ.ic_charset_id = (char *)dst_charset_id;
ssize_t res;
if (src_charset_id == NULL) {
- strncpy(dst, src, dst_size);
- dst[dst_size - 1] = '\0';
+ strlcpy(dst, src, dst_size);
return strlen(dst);
}
templ.ic_charset_id = (char *)src_charset_id;
/* Check config/requested langs */
if ((langs = lang_code_split(lang)) != NULL) {
for (i = 0; i < langs->codeslen; i++) {
- strncpy(skel.lang, langs->codes[i]->code2b, sizeof(skel.lang));
+ strlcpy(skel.lang, langs->codes[i]->code2b, sizeof(skel.lang));
if ((e = RB_FIND(ls, &skel, link, _lang_cmp)))
break;
}
/* Create */
if (!e) {
e = malloc(sizeof(*e) + strlen(str) + 1);
- strncpy(e->lang, lang, sizeof(e->lang));
+ strlcpy(e->lang, lang, sizeof(e->lang));
strcpy(e->str, str);
RB_INSERT_SORTED(ls, e, link, _lang_cmp);
save = 1;
hdr = &h;
http_arg_init(&h);
}
- strncpy(buf_body, body, sizeof(buf_body));
- strncat(buf_body, "\r\n", 2);
+ strlcpy(buf_body, body, sizeof(buf_body));
+ strlcat(buf_body, "\r\n", 2);
snprintf(buf2, sizeof(buf2), "%"PRIu64, (uint64_t)(size + 2));
http_arg_set(hdr, "Content-Length", buf2);
}
s = dvb_fec2str(fec);
if (s == NULL)
return "";
- strncpy(buf, s, sizeof(buf));
- buf[sizeof(buf)-1] = '\0';
+ strlcpy(buf, s, sizeof(buf));
p = strchr(buf, '/');
while (p && *p) {
*p = *(p+1);
pthread_mutex_unlock(&rtsp_lock);
http_error(hc, !rs ? HTTP_STATUS_BAD_SESSION : HTTP_STATUS_NOT_FOUND);
} else {
- strncpy(session, rs->session, sizeof(session));
- session[sizeof(session)-1] = '\0';
+ strlcpy(session, rs->session, sizeof(session));
rtsp_close_session(rs);
rtsp_free_session(rs);
pthread_mutex_unlock(&rtsp_lock);
}
si->si_weight = weight;
si->si_prio = prio;
- strncpy(si->si_source, source ?: "<unknown>", sizeof(si->si_source));
- si->si_source[sizeof(si->si_source)-1] = '\0';
+ strlcpy(si->si_source, source ?: "<unknown>", sizeof(si->si_source));
TAILQ_INSERT_SORTED(sil, si, si_link, si_cmp);
return si;
}
st = elementary_stream_create(&t->s_components, pid, type);
if((v = htsmsg_get_str(c, "language")) != NULL)
- strncpy(st->es_lang, lang_code_get(v), 3);
+ strlcpy(st->es_lang, lang_code_get(v), 4);
if (SCT_ISAUDIO(type)) {
if(!htsmsg_get_u32(c, "audio_type", &u32))
if (*tmp != '/' && prefix)
snprintf(dst, dstsize, "%s/%s", prefix, tmp);
else
- strncpy(dst, tmp, dstsize);
+ strlcpy(dst, tmp, dstsize);
while(*n) {
if(*n == ':' || *n == '?' || *n == '*' || *n > 127 || *n < 32)
if (name[0] == '/') {
if (lstat(name, &st)) return 0;
if (!S_ISREG(st.st_mode) || !(st.st_mode & S_IEXEC)) return 0;
- strncpy(out, name, len);
- out[len-1] = '\0';
+ strlcpy(out, name, len);
return 1;
}
if (!(path = getenv("PATH"))) return 0;
snprintf(bin, sizeof(bin), "%s/%s", tmp, de->d_name);
if (lstat(bin, &st)) continue;
if (!S_ISREG(st.st_mode) || !(st.st_mode & S_IEXEC)) continue;
- strncpy(out, bin, len);
- out[len-1] = '\0';
+ strlcpy(out, bin, len);
ret = 1;
break;
}
inet_ntop(AF_INET6, &(((struct sockaddr_in6*)sa)->sin6_addr), dst, maxlen);
break;
default:
- strncpy(dst, "Unknown AF", maxlen);
+ strlcpy(dst, "Unknown AF", maxlen);
return NULL;
}
#include <pthread.h>
#include "pthread.h"
#include "tvh_locale.h"
+#include "tvh_string.h"
#include "redblack.h"
struct tvh_locale {
if (p == NULL)
p = (char *)"en_US";
- strncpy(dflt, p, sizeof(dflt)-1);
- dflt[sizeof(dflt)-1] = '\0';
+ strlcpy(dflt, p, sizeof(dflt));
for (p = dflt; *p && *p != '.'; p++);
if (*p == '.') *p = '\0';
#include <sys/syscall.h>
#endif
#include "queue.h"
+#include "tvh_string.h"
#include "hts_strtab.h"
#include "htsmsg.h"
#include "tprofile.h"
int tvh_kill_to_sig(int tvh_kill);
-static inline unsigned int tvh_strhash(const char *s, unsigned int mod)
-{
- unsigned int v = 5381;
- while(*s)
- v += (v << 5) + v + *s++;
- return v % mod;
-}
-
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MINMAX(a,mi,ma) MAX(mi, MIN(ma, a))
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
-static inline const char *tvh_str_default(const char *s, const char *dflt)
-{
- return s && s[0] ? s : dflt;
-}
-void tvh_str_set(char **strp, const char *src);
-int tvh_str_update(char **strp, const char *src);
-
int sri_to_rate(int sri);
int rate_to_sri(int rate);
#define scopedgloballock() scopedlock(&global_lock)
-#define tvh_strdupa(n) \
- ({ int tvh_l = strlen(n); \
- char *tvh_b = alloca(tvh_l + 1); \
- memcpy(tvh_b, n, tvh_l + 1); })
-
-static inline const char *tvh_strbegins(const char *s1, const char *s2)
-{
- while(*s2)
- if(*s1++ != *s2++)
- return NULL;
- return s1;
-}
-
typedef struct th_pipe
{
int rd;
int wr;
} th_pipe_t;
-static inline void mystrset(char **p, const char *s)
-{
- free(*p);
- *p = s ? strdup(s) : NULL;
-}
-
void doexit(int x);
int tvhthread_create
/* Calculate the output size needed to base64-encode x bytes. */
#define BASE64_SIZE(x) (((x)+2) / 3 * 4 + 1)
-int put_utf8(char *out, int c);
-
-char *utf8_lowercase_inplace(char *s);
-
static inline int64_t ts_rescale(int64_t ts, int tb)
{
// return (ts * tb + (tb / 2)) / 90000LL;
/* Copy options and path */
if (!fp) {
if (tvhlog_path) {
- strncpy(buf, tvhlog_path, sizeof(buf)-1);
- buf[sizeof(buf)-1] = '\0';
+ strlcpy(buf, tvhlog_path, sizeof(buf));
path = buf;
} else {
path = NULL;
abort(); \
} while (0)
-#define tvh_strlen(s) ((s) ? strlen(s) : 0)
-
-#define tvh_strlcatf(buf, size, ptr, fmt...) \
- do { int __r = snprintf((buf) + ptr, (size) - ptr, fmt); \
- ptr = __r >= (size) - ptr ? (size) - 1 : ptr + __r; } while (0)
-
void tvhlog_backtrace_printf(const char *fmt, ...);
#endif /* __TVH_LOGGING_H__ */
return -1;
memset(&ifreq, 0, sizeof(ifreq));
- strncpy(ifreq.ifr_name, ifname, IFNAMSIZ-1);
+ strlcpy(ifreq.ifr_name, ifname, IFNAMSIZ);
if (ioctl(fd, SIOCGIFADDR, &ifreq) < 0)
return -1;
size_t len = x.afterLast - x.first;\
if (len > sizeof(y) - 1) \
{ y[0] = '\0'; s = strndup(x.first, len); } else \
- { s = NULL; strncpy(y, x.first, len); y[len] = '\0'; }\
+ { s = NULL; strlcpy(y, x.first, len + 1); }\
} else {\
s = NULL;\
y[0] = '\0';\
page->aux = w = calloc(1, sizeof(wizard_hello_t));
if (config.language_ui)
- strncpy(w->ui_lang, config.language_ui, sizeof(w->ui_lang)-1);
+ strlcpy(w->ui_lang, config.language_ui, sizeof(w->ui_lang));
m = htsmsg_csv_2_list(config.language, ',');
f = m ? HTSMSG_FIRST(m) : NULL;
s = htsmsg_field_get_string(f);
if (s == NULL) break;
switch (idx) {
- case 0: strncpy(w->epg_lang1, s, sizeof(w->epg_lang1) - 1); break;
- case 1: strncpy(w->epg_lang2, s, sizeof(w->epg_lang2) - 1); break;
- case 2: strncpy(w->epg_lang3, s, sizeof(w->epg_lang3) - 1); break;
+ case 0: strlcpy(w->epg_lang1, s, sizeof(w->epg_lang1)); break;
+ case 1: strlcpy(w->epg_lang2, s, sizeof(w->epg_lang2)); break;
+ case 2: strlcpy(w->epg_lang3, s, sizeof(w->epg_lang3)); break;
}
f = HTSMSG_NEXT(f);
}
pthread_attr_setstacksize(&_attr, 2*1024*1024);
attr = &_attr;
}
- strncpy(ts->name, "tvh:", 4);
- strncpy(ts->name+4, name, sizeof(ts->name)-4);
- ts->name[sizeof(ts->name)-1] = '\0';
+ strlcpy(ts->name, "tvh:", 5);
+ strlcpy(ts->name+4, name, sizeof(ts->name)-4);
ts->run = start_routine;
ts->arg = arg;
r = pthread_create(thread, attr, thread_wrapper, ts);
ssize_t size = regex->re_posix_match[number].rm_eo - regex->re_posix_match[number].rm_so;
if (size < 0 || size > (size_buf - 1))
return -1;
- memcpy(buf, regex->re_posix_text + regex->re_posix_match[number].rm_so, size);
- buf[size] = '\0';
+ strlcpy(buf, regex->re_posix_text + regex->re_posix_match[number].rm_so, size);
return 0;
#if ENABLE_PCRE || ENABLE_PCRE2
} else {