Skip to main content
Post Closed as "Not suitable for this site" by pxeger, caird coinheringaahing, emanresu A, Dingus, The Fifth Marshal
Became Hot Network Question
added 67 characters in body
Source Link

If you consider the following PHP+C polyglot snippet, there is a problem regarding class property access in the printf call:

#include <stdio.h>
#include <stdlib.h>
#define class struct
#define function 

class Point {
#define public int
    public $x;
    public $y;
};

// M4_INTint
function main()
{
    //struct Point*
    $p = newalloca(sizeof(struct Point ...));
    printf("%d", $p->x);  // PHP expects $p->x, but C expects $p->$x
    return 0;
}

My question is, how to resolve this in a neat manner? Possible solutions:

  1. Remove all $ via sed before compiling with gcc
  2. Define public $x as int x using #if __PHP__
  3. Edit: Use getters, maybe? (works in C by passing self as first argument with function pointers)

Trying to define dollar sign as empty space does not work:

#define $ 

Any other ideas? I am also considering using m4 in the C Makefile. Thank you. :)

If you consider the following PHP+C polyglot snippet, there is a problem regarding class property access in the printf call:

#define class struct
#define function 

class Point {
#define public int
    public $x;
    public $y;
};

// M4_INT
function main()
{
    // $p = new Point ...
    printf("%d", $p->x);  // PHP expects $p->x, but C expects $p->$x
    return 0;
}

My question is, how to resolve this in a neat manner? Possible solutions:

  1. Remove all $ via sed before compiling with gcc
  2. Define public $x as int x using #if __PHP__
  3. Edit: Use getters, maybe? (works in C by passing self as first argument with function pointers)

Trying to define dollar sign as empty space does not work:

#define $ 

Any other ideas? I am also considering using m4 in the C Makefile. Thank you. :)

If you consider the following PHP+C polyglot snippet, there is a problem regarding class property access in the printf call:

#include <stdio.h>
#include <stdlib.h>
#define class struct
#define function 

class Point {
#define public int
    public $x;
    public $y;
};

int
function main()
{
    struct Point*
    $p = alloca(sizeof(struct Point));
    printf("%d", $p->x);  // PHP expects $p->x, but C expects $p->$x
    return 0;
}

My question is, how to resolve this in a neat manner? Possible solutions:

  1. Remove all $ via sed before compiling with gcc
  2. Define public $x as int x using #if __PHP__
  3. Edit: Use getters, maybe? (works in C by passing self as first argument with function pointers)

Trying to define dollar sign as empty space does not work:

#define $ 

Any other ideas? I am also considering using m4 in the C Makefile. Thank you. :)

added 100 characters in body
Source Link

If you consider the following PHP+C polyglot snippet, there is a problem regarding class property access in the printf call:

#define class struct
#define function 

class Point {
#define public int
    public $x;
    public $y;
};

// M4_INT
function main()
{
    // $p = new Point ...
    printf("%d", $p->x);  // PHP expects $p->x, but C expects $p->$x
    return 0;
}

My question is, how to resolve this in a neat manner? Possible solutions:

  1. Remove all $ via sed before compiling with gcc
  2. Define public $x as int x using #if __PHP__
  3. Edit: Use getters, maybe? (works in C by passing self as first argument with function pointers)

Trying to define dollar sign as empty space does not work:

#define $ 

Any other ideas? I am also considering using m4 in the C Makefile. Thank you. :)

If you consider the following PHP+C polyglot snippet, there is a problem regarding class property access in the printf call:

#define class struct
#define function 

class Point {
#define public int
    public $x;
    public $y;
};

// M4_INT
function main()
{
    // $p = new Point ...
    printf("%d", $p->x);  // PHP expects $p->x, but C expects $p->$x
    return 0;
}

My question is, how to resolve this in a neat manner? Possible solutions:

  1. Remove all $ via sed before compiling with gcc
  2. Define public $x as int x using #if __PHP__

Trying to define dollar sign as empty space does not work:

#define $ 

Any other ideas? I am also considering using m4 in the C Makefile. Thank you. :)

If you consider the following PHP+C polyglot snippet, there is a problem regarding class property access in the printf call:

#define class struct
#define function 

class Point {
#define public int
    public $x;
    public $y;
};

// M4_INT
function main()
{
    // $p = new Point ...
    printf("%d", $p->x);  // PHP expects $p->x, but C expects $p->$x
    return 0;
}

My question is, how to resolve this in a neat manner? Possible solutions:

  1. Remove all $ via sed before compiling with gcc
  2. Define public $x as int x using #if __PHP__
  3. Edit: Use getters, maybe? (works in C by passing self as first argument with function pointers)

Trying to define dollar sign as empty space does not work:

#define $ 

Any other ideas? I am also considering using m4 in the C Makefile. Thank you. :)

Source Link

Need some feedback with PHP+C polyglot code and class/struct properties

If you consider the following PHP+C polyglot snippet, there is a problem regarding class property access in the printf call:

#define class struct
#define function 

class Point {
#define public int
    public $x;
    public $y;
};

// M4_INT
function main()
{
    // $p = new Point ...
    printf("%d", $p->x);  // PHP expects $p->x, but C expects $p->$x
    return 0;
}

My question is, how to resolve this in a neat manner? Possible solutions:

  1. Remove all $ via sed before compiling with gcc
  2. Define public $x as int x using #if __PHP__

Trying to define dollar sign as empty space does not work:

#define $ 

Any other ideas? I am also considering using m4 in the C Makefile. Thank you. :)