1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

strcpy -> strlcpy.

Some of these changes doesn't make sense, but warnings are avoided.
This commit is contained in:
witekfl 2010-09-19 15:16:00 +02:00
parent d94d9720a1
commit 365cbb61be
4 changed files with 16 additions and 13 deletions

View File

@ -206,10 +206,12 @@ set_language(int language)
/* We never free() this, purely intentionally. */
LANGUAGE = malloc(256);
}
strcpy(LANGUAGE, language_to_iso639(language));
if (LANGUAGE) {
strlcpy(LANGUAGE, language_to_iso639(language), 256);
p = strchr(LANGUAGE, '-');
if (p)
*p = '_';
}
/* Propagate the change to gettext. From the info manual. */
{

View File

@ -142,10 +142,9 @@ __(unsigned char *file, unsigned int line, unsigned char *func,
file, line, func, last_line);
}
/* Risky ;) */
strcpy(last_file, file);
strcpy(last_func, func);
strcpy(last_result, result);
strlcpy(last_file, file, 512);
strlcpy(last_func, func, 1024);
strlcpy(last_result, result, 16384);
last_line = line;
return result;

View File

@ -155,9 +155,9 @@ get_charset_aliases(void)
res_size = 0;
break;
}
strcpy(res_ptr + res_size - (l2 + 1) - (l1 + 1),
buf1);
strcpy(res_ptr + res_size - (l2 + 1), buf2);
strlcpy(res_ptr + res_size - (l2 + 1) - (l1 + 1),
buf1, l1 + 1 + l2 + 1 + 1);
strlcpy(res_ptr + res_size - (l2 + 1), buf2, l2 + 1);
}
fclose(fp);
if (res_size == 0)

View File

@ -874,6 +874,7 @@ join_urls(struct uri *base, unsigned char *rel)
int add_slash = 0;
int translate = 0;
int length = 0;
int rel_len;
/* See RFC 1808 */
/* TODO: Support for ';' ? (see the RFC) --pasky */
@ -988,12 +989,13 @@ join_urls(struct uri *base, unsigned char *rel)
}
length = path - struri(base);
uristring = mem_alloc(length + strlen(rel) + add_slash + 1);
rel_len = strlen(rel);
uristring = mem_alloc(length + rel_len + add_slash + 1);
if (!uristring) return NULL;
memcpy(uristring, struri(base), length);
if (add_slash) uristring[length] = '/';
strcpy(uristring + length + add_slash, rel);
strlcpy(uristring + length + add_slash, rel, rel_len + 1);
return normalize_uri_reparse(uristring);
}