C variable length parameter

Source: Internet
Author: User

The variable-length parameters are mentioned earlier:

Last but not least: the first parameter is the form of a subsequent parameter , format.i.e. Printf

What I want to say in this article is the problem of insecurity-.-! Actually, I'm messing around.

First on the code

#include <stdio.h>#include<stdlib.h>#include<stdarg.h>voidSubfunc (Char*format,...) {    inti;    Va_list ap;    Va_start (Ap,format);  for(i=0; format[i]!=' /'; i++){        Switch(Format[i]) { Case 's': printf ("%s\n", Va_arg (AP,Char*));  Break;  Case 'D': printf ("%d\n", Va_arg (AP,int));  Break; default: printf ("format over.\n");  Break;    }} va_end (AP); return;}voidfunc () {inta[ -]; intI=0;  for(i=0;i< -; i++) A[i]=-1; Subfunc ("ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",1); return;};intMainvoid){    intpause;        Func (); scanf ("%d",&pause); return 0;}
C Code

What I want to do in this code is to read the data of the function below the function stack in the sub-function (or the function above the function stack).

In the notation of a variable-length parameter, a parameter is the form of a subsequent parameter, so if we supply the number of arguments after the first parameter, the number required for the first parameter is different. Then you should read the data below the function stack .

Now that you can read the data of the function below the function stack, you can naturally get information such as the return address of the following function , then you can disguise the return? Pending testing ...

C variable length parameter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.