Warning

 

Close
Confirm Action

Are you sure you wish to do this?

Cancel Confirm
AR15.COM
Previous Page
/ 3
Next Page
4/13/2017 11:20:28 PM EDT


memcpy(messagebuffer.IPv6addr, globalIPv6addr_from_UNCI, strlen(messagebuffer.IPv6addr) );

Freshmen college programmers: why is this code == pure DUMBASS SHIT?

TL;DR: field issue I was asked to look at where device could connect IPv6 some of the time, very strange addresses refused other times. LOL.
4/13/2017 11:23:04 PM EDT
[#1]
sooo.........



Then would an American program this better?
4/13/2017 11:23:44 PM EDT
[#2]
Hint: this code gets called for several connections with different addresses.

ETA: THIS one would, but you aren't a developer, are you?
4/13/2017 11:24:30 PM EDT
[#3]
Quote History
Quoted:
sooo.........



Then would an American program this better?
View Quote
Yes but it would cost too much so...
4/13/2017 11:25:04 PM EDT
[#4]
Quote History
Quoted:
sooo.........



Then would an American program this better?
View Quote
An American would ask why we are copying, to Y, an amount of X equal to Y.

And we'd kick the motherfucker that forced us to use IPv6 in the teeth because they were probably the same fucks that were wasteful with IPv4 address space.
4/13/2017 11:27:15 PM EDT
[#5]
Guys. This isn't just bad code. This is BROKEN code. This is "fail-the-job-interview-with-me-if-you-don't-know-why".
4/13/2017 11:28:12 PM EDT
[#6]
why are you thinking about work at 11:30 lol
4/13/2017 11:28:23 PM EDT
[#7]
Quote History
Quoted:
An American would ask why we are copying, to Y, an amount of X equal to Y.

And we'd kick the motherfucker that forced us to use IPv6 in the teeth because they were probably the same fucks that were wasteful with IPv4 address space.
View Quote View All Quotes
View All Quotes
Quote History
Quoted:
Quoted:
sooo.........



Then would an American program this better?
An American would ask why we are copying, to Y, an amount of X equal to Y.

And we'd kick the motherfucker that forced us to use IPv6 in the teeth because they were probably the same fucks that were wasteful with IPv4 address space.
This.

The only thing to do with IPv6 is to turn it off ASAP before it screws everything up.
Stupid idea from the same assholes that bought you Y2K.
4/13/2017 11:29:04 PM EDT
[#8]
Quote History
Quoted:
Guys. This isn't just bad code. This is BROKEN code.
View Quote
It's not broken if messagebuffer.IPv6addr is already 128 bits, and globalIPv6addr_from_UNCI is a valid 128 bit IPv6 address.
4/13/2017 11:29:22 PM EDT
[#9]
I'm drinking rum because I fixed the problem and have tomorrow off.

ETA: BZZZZZZT Wrong. Thanks for playing.
4/13/2017 11:29:55 PM EDT
[#10]
Nah dude, there's no way h1b has rampant abuse as a feature of the system.




4/13/2017 11:32:47 PM EDT
[#11]
It's all Hindi to me.
4/13/2017 11:33:51 PM EDT
[#12]
Hint 2: both source and destination are 16 byte arrays, and source globalIPv6addr_from_UNCI has the valid address, but the dest don't always after the call.

Either this will go potato fast and end up un page 10 soon, or a developer will show up and LOL with me.
4/13/2017 11:34:23 PM EDT
[#13]
Quoted:


memcpy(messagebuffer.IPv6addr, globalIPv6addr_from_UNCI, strlen(messagebuffer.IPv6addr) );

Freshmen college programmers: why is this code == pure DUMBASS SHIT?

TL;DR: field issue I was asked to look at where device could connect IPv6 some of the time, very strange addresses refused other times. LOL.
View Quote


What's the big deal? I mean as long as you've used messagebuffer.IPv6addr at least once before, it should be the right length! Wait... do I want to see what the malloc call looks like?

And I'm sure there's no way that the length of globalIPv6addr_from_UNCI is ever different from the length of messagebuffer.IPv6addr.. better test it on ::1 and then see what kind of magic shit I can write into messagebuffer.IPv6addr

And are you literally passing the IPv6 addresses as strings, or as some more appropriate data structure and you overrode strlen() for some reason?

And while we're at it, the mix of camelCase and underscores in a single variable makes my eye twitch.

Although I haven't done anything in C for like 6 years.
4/13/2017 11:35:42 PM EDT
[#14]
10 PRINT @Kubota3430
20 GOTO 10
4/13/2017 11:38:02 PM EDT
[#15]
no context, if the sizes are fixed it's fine. If they are not use a different function. perhaps the length function is not returning the expected result.
4/13/2017 11:38:45 PM EDT
[#16]
Quote History
Quoted:
Hint 2: both source and destination are 16 byte arrays, and source globalIPv6addr_from_UNCI has the valid address, but the dest don't always after the call.

Either this will go potato fast and end up un page 10 soon, or a developer will show up and LOL with me.
View Quote
Hint 3:

If you're still debugging an H1B's C++ code in 2017, you've made some poor career choices along the way.
4/13/2017 11:38:52 PM EDT
[#17]
PS I know the guy that wrote this. He's long gone to another company after he lawyer-ed up and got a green card. This shit has been lying dormant since 2007. Not a bad dude, just left me a nice fucking timebomb turd of a bug that until the customer started REALLY using IPv6 didn't get exposed....
4/13/2017 11:40:02 PM EDT
[#18]
Quote History
Quoted:


An American would ask why we are copying, to Y, an amount of X equal to Y.

And we'd kick the motherfucker that forced us to use IPv6 in the teeth because they were probably the same fucks that were wasteful with IPv4 address space.
View Quote
What's wrong with IPv6? It's a much more elegant solution than subnetting all the things, right?
4/13/2017 11:40:05 PM EDT
[#19]
Quote History
Quoted:

Hint 3:

If you're still debugging an H1B's C++ code in 2017, you've made some poor career choices along the way.
View Quote
Fuck off. I'm the pro from Dover who was called in to save the day AND DID. You're just trying to piss in my Cheerios because you don't know what's wrong.
4/13/2017 11:40:15 PM EDT
[#20]
Off By One, @strlen() ?
4/13/2017 11:41:05 PM EDT
[#21]
Quote History
Quoted:
Off By One, @strlen() ?
View Quote
Getting warmer but no cigar yet!
4/13/2017 11:42:19 PM EDT
[#22]
strlen on the wrong variable
4/13/2017 11:42:24 PM EDT
[#23]
Seems like we should be specifying the number of bytes in the source, not the destination, as the number of bytes to copy.  Also probably should be using strcpy.
4/13/2017 11:43:48 PM EDT
[#24]
In this thread we learn GD actually stands for "Geek Discussion".

And I say that as a UC geek.
4/13/2017 11:43:51 PM EDT
[#25]
Quote History
Quoted:


Fuck off. I'm the pro from Dover who was called in to save the day AND DID. You're just trying to piss in my Cheerios because you don't know what's wrong.
View Quote
strlen results in undefined as it is measuring an a 16 byte array and cannot read a terminating null character.
4/13/2017 11:45:22 PM EDT
[#26]
fRedr: still warm.

Undefined: wow you are getting really hot but no PMag yet!
4/13/2017 11:46:20 PM EDT
[#27]
Quote History
Quoted:
fRedr: still warm.

Undefined: wow you are getting really hot but no PMag yet!
View Quote
Considering the last time I spent any significant time working in C++ was before PMAGs existed, I can live with that.
4/13/2017 11:46:57 PM EDT
[#28]
Reminds me of dailywtf, haven't been there in a while. Thanks for the nostalgia.

Are you storing addr's as strings?

If not does he really think the sizeof an ipv6 address needs to be calculated at runtime?

TFW you know to check the destination buffer size but you use strlen, keep the h1bs flowing guys. I work in security research. Indefinite job security.
4/13/2017 11:48:22 PM EDT
[#29]
Quote History
Quoted:


Fuck off. I'm the pro from Dover who was called in to save the day AND DID. You're just trying to piss in my Cheerios because you don't know what's wrong.
View Quote
4/13/2017 11:49:27 PM EDT
[#30]
Quote History
Quoted:


strlen results in undefined as it is measuring an a 16 byte array and cannot read a terminating null character.
View Quote
Do we know that's actually what it's measuring? They could be passing around the address as a char*, and strlen(char*) returns the length of the initialized string, not the declared size.

char IPv6addr[40] = '2001:0db8:ac10:fe01::'
strlen(IPv6Addr) is 21
sizeof(Ipv6Addr) is 40
4/13/2017 11:51:00 PM EDT
[#31]
If the source contains a string, we probably should be adding one more byte to the number of bytes to copy so we end up with a valid string with null terminator at the destination...for whoever reads it.
4/13/2017 11:51:32 PM EDT
[#32]
Not strings - both source and destination are simple arrays of bytes, msb first. Simple like this:

ui8 IPv6addr[16]; // ui8 is unsigned byte

C'mon Undefined, you are SO close.
4/13/2017 11:51:38 PM EDT
[#33]
Missing the +1 in the strlen?
4/13/2017 11:51:50 PM EDT
[#34]
somebody put a "comma" punchcard in the stack.
4/13/2017 11:52:10 PM EDT
[#35]
Quote History
Quoted:


strlen results in undefined as it is measuring an a 16 byte array and cannot read a terminating null character.
View Quote
Can't be undefined it'll either find a null eventually or hit unmapped memory and throw an access violation.
4/13/2017 11:53:14 PM EDT
[#36]
Quote History
Quoted:


Can't be undefined it'll either find a null eventually or hit unmapped memory and throw an access violation.
View Quote
You are on fire. But no PMag!

ETA: think simpler!
4/13/2017 11:54:30 PM EDT
[#37]
Quote History
Quoted:


You are on fire. But no PMag!

ETA: think simpler!
View Quote
I already answered you, he meant to use sizeof().
4/13/2017 11:55:36 PM EDT
[#38]
Quote History
Quoted:


I already answered you, he meant to use sizeof().
View Quote
That ain't why the device fails in the field. This is compiled delivered code and there's no compile error. But you are on to something...
4/13/2017 11:56:10 PM EDT
[#39]
Allow me to fire up my commodore 64 and find a solution in an issue of Byte.  Be right back...
4/13/2017 11:56:13 PM EDT
[#40]
Can I control memory adjacent to globalIPv6addr_from_UNCI?
4/13/2017 11:56:13 PM EDT
[#41]
Counting size of destination instead of source.
4/13/2017 11:57:32 PM EDT
[#42]
Quote History
Quoted:
Allow me to fire up my commodore 64 and find a solution in an issue of Byte.  Be right back...
View Quote
If you post a pic of your com 64, with a sheet of paper with "FU AROCK" on it and today's date, I will send you a free PMAG.
4/13/2017 11:58:55 PM EDT
[#43]
OK last hint: a string in mem is an array of bytes terminated with a null byte. strlen() is a string function.
4/13/2017 11:59:17 PM EDT
[#44]
Quote History
Quoted:


That ain't why the device fails in the field. This is compiled delivered code and there's no compile error. But you are on to something...
View Quote
Oh why will it crash sometimes?

Because sometimes there can be a null in various locations in the uninitialized memory he's performing strlen on, sometimes its within the sizeof an ipv6 address and you get partial copies, sometimes its not and you overwrite the next member in the structure.
4/13/2017 11:59:35 PM EDT
[#45]
Quoted:
memcpy(messagebuffer.IPv6addr, globalIPv6addr_from_UNCI, strlen(messagebuffer.IPv6addr) );
View Quote
Are the addresses strings? Truncated copy when the previous value of the destination was shorter than globalIPv6addr_from_UNCI.

If the addresses are numeric: truncated copy on zero byte in address value. Also, lots of buffer overrun potential.
4/14/2017 12:00:08 AM EDT
[#46]
All true but not the bug. No not strings, just simple unsigned byte array of [16].

ETA you kind of skirted around the answer but the closest so far. Almost an X.
4/14/2017 12:03:59 AM EDT
[#47]
I'm going to mix one more drink and walk the dag, when I come back I'll sum it up.

As I said before, I know who wrote this and I kinda like the guy. He must have fucked up a copy-paste, because he wrote some good code otherwise LOL, and whomever was in the code review before he commited was asleep at the wheel...
4/14/2017 12:08:53 AM EDT
[#48]
Ipv6 address can have a null in the actual address
4/14/2017 12:13:23 AM EDT
[#49]
Quote History
Quoted:
An American would ask why we are copying, to Y, an amount of X equal to Y.

And we'd kick the motherfucker that forced us to use IPv6 in the teeth because they were probably the same fucks that were wasteful with IPv4 address space.
View Quote View All Quotes
View All Quotes
Quote History
Quoted:
Quoted:
sooo.........



Then would an American program this better?
An American would ask why we are copying, to Y, an amount of X equal to Y.

And we'd kick the motherfucker that forced us to use IPv6 in the teeth because they were probably the same fucks that were wasteful with IPv4 address space.
I hate those guys with the heat of a thousand dying suns

Just yesterday I had to beg, borrow, and steal to scrape together and provision a small /29 sized block of statics for an enterprise customer.
4/14/2017 12:16:56 AM EDT
[#50]
I have no idea what's going on in here, I don't do the C. But I'd move the source and destinations outside of the function, make sure not null,  but I'm not that type of developer.
Previous Page
/ 3
Next Page