Author: stsp
Date: Wed Nov 25 20:27:38 2009
New Revision: 884250
URL: http://svn.apache.org/viewvc?rev=884250&view=rev
Log:
Replace use of strcpy() in libsvn_fs_fs, my compiler keeps complaining.
* subversion/libsvn_fs_fs/fs_fs.c
(get_shared_txn): Use strncpy() instead of strcpy(). Make sure to
NUL-terminate the string in all cases.
(recover_find_max_ids): As above, and also add assertions of the
source string length similar to the assertion in get_shared_txn(),
so we can, at least in debug mode, detect truncation.
Modified:
subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
Modified: subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c?rev=884250&r1=884249&r2=884250&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c Wed Nov 25 20:27:38 2009
@@ -457,7 +457,8 @@
}
assert(strlen(txn_id) < sizeof(txn->txn_id));
- strcpy(txn->txn_id, txn_id);
+ strncpy(txn->txn_id, txn_id, sizeof(txn->txn_id) - 1);
+ txn->txn_id[sizeof(txn->txn_id) - 1] = '\0';
txn->being_written = FALSE;
/* Link this transaction into the head of the list. We will typically
@@ -6627,9 +6628,17 @@
copy_id = svn_fs_fs__id_copy_id(id);
if (svn_fs_fs__key_compare(node_id, max_node_id) > 0)
- strcpy(max_node_id, node_id);
+ {
+ assert(strlen(node_id) < MAX_KEY_SIZE);
+ strncpy(max_node_id, node_id, MAX_KEY_SIZE - 1);
+ max_node_id[MAX_KEY_SIZE - 1] = '\0';
+ }
if (svn_fs_fs__key_compare(copy_id, max_copy_id) > 0)
- strcpy(max_copy_id, copy_id);
+ {
+ assert(strlen(copy_id) < MAX_KEY_SIZE);
+ strncpy(max_copy_id, copy_id, MAX_KEY_SIZE - 1);
+ max_copy_id[MAX_KEY_SIZE - 1] = '\0';
+ }
if (kind == svn_node_file)
continue;