Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 215529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:28:44+00:00 2026-05-11T18:28:44+00:00

I recently stumbled across an article that claims Microsoft is banning the memcpy() function

  • 0

I recently stumbled across an article that claims Microsoft is banning the memcpy() function in its secure programming shops. I understand the vulnerabilities inherent in the function, but is it necessary to ban its use entirely?

Should programs I write be avoiding memcpy() entirely, or just ensuring that it’s used safely? What alternatives exist that provide similar but safer functionalilty?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:28:44+00:00Added an answer on May 11, 2026 at 6:28 pm

    Microsoft provides alternatives to memcpy and wmemcpy that validate their parameters.

    memcpy_s says, “Hmm, before I read from this address, let me verify for myself that it is not a null pointer; and before I write to this address, I shall perform that test again. I shall also compare the number of bytes I have been requested to copy to the claimed size of the destination; if and only if the call passes all these tests shall I perform the copy.”

    memcpy says “Stuff the destination into a register, stuff the source into a register, stuff the count into a register, perform MOVSB or MOVSW.” (Example on geocities, not long for this world: http://www.geocities.com/siliconvalley/park/3230/x86asm/asml1013.html)

    Edit: For an example in the wild of the Your Wish Is My Command approach to memcpy, consider OpenSolaris, where memcpy is (for some configurations) defined in terms of bcopy, and bcopy (for some configurations) is …

    void
         33 bcopy(from, to, count)
         34 #ifdef vax
         35     unsigned char *from, *to;
         36     int count;
         37 {
         38 
         39     asm("   movc3   12(ap),*4(ap),*8(ap)");
         40 }
         41 #else
         42 #ifdef u3b      /* movblkb only works with register args */
         43     unsigned char *from, *to;
         44     int count;
         45 {
         46     asm("   movblkb %r6, %r8, %r7");
         47 }
         48 #else
         49     unsigned char *from, *to;
         50     int count;
         51 {
         52     while ((count--) > 0)
         53         *to++ = *from++;
         54 }
         55 #endif
    

    Edit: Thanks, Millie Smith! Here is what was on the geocities page I linked above:

    MOVS

    The instruction movs is used to copy source string into the destination (yes, copy, not move). This instruction has two variants: movsb and movsw. The movsb (“move string byte”) moves one byte at a time, whereas movsw moves two bytes at a time.

    Since we’d like to move several bytes at a time, these movs instructions are done in batches using rep prefix. The number of movements is specified by CX register. See the example below:

    :
    lds   si, [src]
    les   di, [dest]
    cld
    mov   cx, 100
    rep   movsb
    :
    

    This example will copy 100 bytes from src to dest. If you replace movsb with movsw, you copy 200 bytes instead. If you remove the rep prefix, the CX register will have no effect. You will move one byte (if it is movsb, or 2 bytes if it is movsw).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 175k
  • Answers 175k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There may be a more elegant solution but: I had… May 12, 2026 at 3:05 pm
  • Editorial Team
    Editorial Team added an answer You could use a regex with preg_match, like this :… May 12, 2026 at 3:05 pm
  • Editorial Team
    Editorial Team added an answer If you are thinking of a fixed color table, just… May 12, 2026 at 3:05 pm

Related Questions

I've been trying to figure out the best way to handle incoming email in
I have recently stumbled across an issue where the WPF ListView control seems to
This is starting to vex me. I recently decided to clear out my FTP,
I recently stumbled across this entry in the google testing blog about guidelines for

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.