Security Audit 5:13. Use proper length on strncpy.

This commit is contained in:
Jim Norman
2006-04-26 21:38:59 +00:00
parent 5345082354
commit 51da351af7
2 changed files with 8 additions and 4 deletions

View File

@@ -756,8 +756,8 @@ void ItemGetInfoCb( GnomeKeyringResult result,
if (itemlen > maxlen) {
itemInfo->displayName = NULL;
} else {
strncpy(itemInfo->displayName, item, maxlen);
itemInfo->displayName[maxlen] = '\0';
strncpy(itemInfo->displayName, item, itemlen);
itemInfo->displayName[itemlen] = '\0';
}
/* maxlen = 255. This should be one less than the size of
@@ -768,8 +768,8 @@ void ItemGetInfoCb( GnomeKeyringResult result,
if (itemlen > maxlen) {
itemInfo->secret = NULL;
} else {
strncpy(itemInfo->secret, item, maxlen);
itemInfo->secret[maxlen] = '\0';
strncpy(itemInfo->secret, item, itemlen);
itemInfo->secret[itemlen] = '\0';
}
itemInfo->mTime = gnome_keyring_item_info_get_mtime(info);