Bloomberg LP Interview Question for Financial Software Developers






Comment hidden because of low score. Click to expand.
2
of 2 vote

It's a security hazard if the passed destination string doesn't have null character ('\0') at the end. The iteration could continue indefinite till it see such a null character.

The strncpy could be used instead if we know how many bytes to copy.

- Anonymous January 09, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Buffer overflow situation."Standard" solution to fixed it is to use the standard libraries calls.

- Anonymous January 09, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

instead, could use ctrncpy

- shoushou January 09, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

strncpy, sorry

- shoushou January 09, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what strcpy does is copy the string character by character. a char size is 1 byte but usually the internal bus size is greater than 8 thus strcpy doesn't utilize complete bus.

- XXX January 13, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

strcpy doesnot check for overlapping address-es of source and destination .So the source might get modified with deliberate input.

- SRK July 14, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

In strcpy(p1,p2), if p1 and p2 overlap, there could be a problem. Memmove() solves this.

- S.M September 18, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

In strcpy(p1,p2), if p1 and p2 overlap, there could be a problem. Memmove() solves this.

- mohammed September 18, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

also consider following example

char *p2 = "sachin";
     char *p1 = NULL;  
     strcpy(p1,p2); //segfault

     strcpy does not check for NULL pointers ;

- sachin February 27, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Use strlcpy.
Look at its man page, it is different than strncpy.

The problem is that we should not overflow destination buffer. strlcpy does the copy upto destination buffer size and also guarantees null termination of destination.

- Snapwink November 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

There is no drawback. Blame the shooter, not the gun.

It is the programmer at fault if he cannot do proper bounds checking before using strcpy.

- NRA January 10, 2009 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More