Windows Security-Enhanced CRT 相关函数(即_s后辍函数)并不是对老函数的直接替代,其中不仅有更严格的参数检查,还会有buffer的重置操作等,使用的时候要格外小心,一定要仔细阅读MSDN描述或者VC runtime源码 (以Visual Studio 2008为例: C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\crt\src)。
下面不妨测试3个代码片段:
测试代码【C1】:
void main() {
char dst1[8];
memcpy(dst1, NULL, 0);
memcpy(NULL, NULL, 0);
}
测试代码【C2】:
void main() {
char dst1[8];
memcpy_s(dst1, 8, NULL, 0);
memcpy_s(NULL, 0, NULL, 0);
char *dst2 = (char *)malloc(0);
if (dst2) {
memcpy_s(dst2, 0, NULL, 0);
free(dst2);
}
}
测试代码【C3】:
void main() {
char dst1[8];
memcpy_s(NULL, 0, dst1, 8);
char *dst2 = (char *)malloc(0);
if (dst2) {
memcpy_s(dst2, 0, dst1, 8);
free(dst2);
}
}
这几段代码实际上什么也没有做,只是参数有变化而已,但测试中会发现【C3】会导致程序崩溃。具体原因就是因为memcpy_s进行了更严格的参数检测,可对参考memcpy_s的源码,引用自Visual Studio 2008 runtime source memcpy_s.c:
/***
* memcpy_s.c - contains memcpy_s routine
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* Purpose:
* memcpy_s() copies a source memory buffer to a destination buffer.
* Overlapping buffers are not treated specially, so propagation may occur.
*
*******************************************************************/
#include <cruntime.h>
#include <string.h>
#include <internal.h>
/***
* memcpy_s - Copy source buffer to destination buffer
*
* Purpose:
* memcpy_s() copies a source memory buffer to a destination memory buffer.
* This routine does NOT recognize overlapping buffers, and thus can lead
* to propagation.
*
* For cases where propagation must be avoided, memmove_s() must be used.
*
* Entry:
* void *dst = pointer to destination buffer
* size_t sizeInBytes = size in bytes of the destination buffer
* const void *src = pointer to source buffer
* size_t count = number of bytes to copy
*
* Exit:
* Returns 0 if everything is ok, else return the error code.
*
* Exceptions:
* Input parameters are validated. Refer to the validation section of the function.
* On error, the error code is returned and the destination buffer is zeroed.
*
*******************************************************************/
errno_t __cdecl memcpy_s(
void * dst,
size_t sizeInBytes,
const void * src,
size_t count
)
{
if (count == 0)
{
/* nothing to do */
return 0;
}
/* validation section */
_VALIDATE_RETURN_ERRCODE(dst != NULL, EINVAL);
if (src == NULL || sizeInBytes < count)
{
/* zeroes the destination buffer */
memset(dst, 0, sizeInBytes);
_VALIDATE_RETURN_ERRCODE(src != NULL, EINVAL);
_VALIDATE_RETURN_ERRCODE(sizeInBytes >= count, ERANGE);
/* useless, but prefast is confused */
return EINVAL;
}
memcpy(dst, src, count);
return 0;
}
参考阅读:
cost of propecia ireland Randomised double blind trial of megestrol acetate vs placebo in treatment naive advanced hepatocellular carcinoma
Heard some buzz about shahspin, decided to check it out. It’s a fairly simple game, but sometimes that’s all you need! You can find it at shahspin
75betlogin is alright, nothing spectacular but a decent place to mess around for a bit. Get in on the action here: 75betlogin
Alright Beephcasino, let’s be real. I’ve been around the block and this casino has some serious potential. Good game selection and seems legit. Give it a spin! beephcasino
$950 per week for uploading photos on Facebook ! We’re urgently looking for ordinary Facebook users who can post photos and videos on Facebook. We’ll pay you $950 per week. We’re currently working with a Los Angeles-based clothing e-commerce brand that’s looking for ordinary people to manage posting photos on their Facebook page on behalf of them. There’s still an open spot readily available for you. Here are the details: http://social-media-jobs.advertising4you.co.uk
References:
Legiano Casino Lizenz https://wiki.opendesign.com/
References:
KingMaker Casino Anmelden https://link.mym.ge/odellburnett3
References:
Kingmaker casino skrill einzahlung https://goz.vn/jeromeagee
References:
KingMaker Casino 100% Einzahlungsbonus https://linksminify.com/carrieblohm017
References:
KingMaker Casino Einzahlung sofort upangmarga.go.id
References:
KingMaker Casino Einzahlung per Handyguthaben https://zm.goodinternet.org/en/external-link/?next=https://de.trustpilot.com/review/beyondjewellery.de
References:
KingMaker Casino Einzahlung und Bonus https://forum.mds.ru/
References:
KingMaker Casino High Roller Bonus https://sites.fastspring.com
References:
KingMaker Casino App Download Bonus http://orienteering.sport
References:
KingMaker Casino Einzahlung per Paysafecard http://www.htcdev.com/?URL=de.trustpilot.com/review/beyondjewellery.de/
References:
KingMaker Casino Willkommensbonus Einzahlung
https://podnova.com/player/player_add_frame.php?url=https://de.trustpilot.com/review/beyondjewellery.dehttps://podnova.com/player/player_add_frame.php?url=https://de.trustpilot.com/review/beyondjewellery.de</a
References:
KingMaker Casino App Download Bonus https://trac.dpi.inpe.br/terrama2/search?q=https://de2wa.com/brennaaponte28
References:
Legiano maps.google.hu
References:
Legiano Casino Bonus ohne Einzahlung http://www.google.co.th/
References:
Legiano Casino Gutschein https://audiosex.pro/proxy.php?link=https://telegra.ph/Legiano-Casino-Bonus-ohne-Einzahlung-Freispiele–Promo-Codes-06-07
References:
Legiano Casino Willkommensbonus http://nou-rau.uem.br/nou-rau/zeus/auth.php?back=https://telegra.ph/Legiano-casino-login-konto-erstellen-wie-anmelden-06-07-3&go=x&code=x&unit=x
References:
Legiano Casino Bewertung http://prod-dbpedia.inria.fr/describe/?url=http://buyandsellhair.com/author/packetpike15/
References:
KingMaker einzahlung sofortüberweisung http://cse.google.co.ke
References:
KingMaker Casino Einzahlung 2025 https://frontier.astroempires.com
References:
Kingmaker casino banküberweisung einzahlen http://dsl.sk/
References:
Legiano Casino Live Chat tiwar.ru
References:
Legiano Casino Gutscheincode http://maps.google.dz
References:
Legiano Casino Einzahlung https://board-en.piratestorm.com/
References:
KingMaker Casino Neukundenbonus Einzahlung https://js.11467.com/
References:
Kingmaker casino skrill einzahlung freethesaurus.com
References:
Leggiano Casino https://m.en.acmedelavie.com/
References:
KingMaker Casino 50 Freispiele nach Einzahlung https://www.gaiaonline.com/
References:
Kingmaker casino google pay einzahlen http://clients1.google.com.gi/url?q=https://s.nas.vn/brigettedelpra
References:
Kingmaker casino paypal einzahlung https://www.ooopic.com/intro/link/show/?target=//sysurl.online/mylespayton782
References:
Legiano Casino Bonus ohne Einzahlung google.com.co
References:
KingMaker Casino Einzahlung per Kreditkarte https://rpms.ru/action.redirect/url/aHR0cHM6Ly9hbGxiaW8ubGluay9kYWx0b25zaG9j
References:
Legiano Casino Neukundenbonus analit.ru
References:
Hitnspin casino willkommensbonus http://clients1.google.com.vn/url?q=https://uplink.in.gov/CSS/logout.htm?url=https://de.trustpilot.com/review/der-wikinger-shop.de
References:
Hit’n’spin casino 25 euro bonus ohne einzahlung https://avtomir365.ru
References:
Hitnspin casino echtgeld https://www.rybalka44.ru
References:
Monro Casino Krypto https://skyblock.net/
References:
Hitnspin bonus ohne einzahlung http://cse.google.com.gh/
References:
Monro Casino PayPal https://www.newhydro.ru/action.redirect/url/aHR0cHM6Ly9saW5jYXJ4LmNvbS9GVW0
References:
Hitnspin casino gutscheincode http://clients1.google.kz
References:
Hit’n’spin casino 25 euro bonus ohne einzahlung http://www.fouillez-tout.com
References:
Hit’n’spin casino no deposit bonus cse.google.com.np
References:
Hit spin casino http://lampadom.net/
References:
Hitnspin casino app iphone http://omga.su/
References:
Hitnspin casino bonus ohne einzahlung http://forum.vhfdx.ru/go.php?url=aHR0cHM6Ly93d3cuZGl2aW5hZ3JhY2lhLmVkdS5lYy9wcm9maWxlL2dpbG1vcmVrdWFncmV2ZTUzOTkwL3Byb2ZpbGU
References:
Hitnspin login https://podnova.com/player/player_add_frame.php?url=https://www.holycrossconvent.edu.na/profile/mohammadlnffletcher49744/profilehttps://podnova.com/player/player_add_frame.php?url=https://www.holycrossconvent.edu.na/profile/mohammadlnffletcher49744/profile</a