AIX 5.3 vs Solaris 5.10 - C strcat implementation

Does anyone have any idea of why this could happen? I have a C program in AIX 5.3, I've been asked to run it on a SPARC Solaris 10 machine, but when I did it, I noticed there was a buffer overflow with one of the many reckless strcat uses. My goal is not to sanitize the code but to provide a concrete and well founded answer of why does this overflow happens on Solaris and not on AIX being the exact same bad coded program. I've been reading a bit about if this could be caused by: 1. endianess diffs between AIX and Solaris. 2. Execution of the strcat function (AIX copies right to left and Solaris left to right) but I haven't been able to find any documentation on this. 3. Plain and simple luck that this issue doesn't occur on AIX. Any light you could shed on this is highly appreciated. EDIT: could this be avoided with the noexec_user_stack flag on solaris?

EDIT 2: Does anyone have any info on the way both OSes do the actual byte copying? in a situation like the option 2 above? EDIT 3: Here's the chunk of code: ` /*global*/ char bufferA[101]; /*inside function*/ bufferA[0]='\0'; strcpy(bufferA,"1"); if (atoi(something)==0) { strcat(bufferA,pieces_of_data); count ++ ; } ` obviously theres more of it but this is the only part where bufferA is being used, and there 2 variables declared global after bufferA that become corrupted with the last part of the last string appended to bufferA. As i said before, if i change the declaration from 101 to 201 the corruption does not occur. EDIT 4: does anyone know anything about the -misalign and -misalign2 compiler options on solaris? could there be any light with these options? Actually a better question would be: is there any difference between AIX powerPC and Solaris SPARC regarding alignment? altough this is probably a question for serverfault but please share if you know something.
noexec_user_stack will just ensure that if it overflows into the stack frame your program will crash sooner instead of attempting to execute instructions from a stack address you accidentally pointed to and then crashing.

以上就是AIX 5.3 vs Solaris 5.10 - C strcat implementation的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准