Bug 3102 - Compilation error in sshbuf-misc.c on IRIX 6.5 with MIPSPro 7.4
Summary: Compilation error in sshbuf-misc.c on IRIX 6.5 with MIPSPro 7.4
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Miscellaneous (show other bugs)
Version: 8.1p1
Hardware: MIPS64 IRIX
: P5 minor
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_8_2
  Show dependency treegraph
 
Reported: 2019-12-02 01:58 AEDT by Ole Weidner
Modified: 2021-04-23 14:59 AEST (History)
2 users (show)

See Also:


Attachments
check if memmem is declared and use for compat prototype (730 bytes, patch)
2019-12-09 12:55 AEDT, Darren Tucker
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ole Weidner 2019-12-02 01:58:45 AEDT
cc-1515 c99: ERROR File = sshbuf-misc.c, Line = 225
  A value of type "int" cannot be assigned to an entity of type "void *".

        if ((p = memmem(sshbuf_ptr(b) + start_offset,


This can be easily fixed by changing line 215 from

        void *p;

to 

        size_t p;
Comment 1 Darren Tucker 2019-12-02 12:26:00 AEDT
(In reply to Ole Weidner from comment #0)
> cc-1515 c99: ERROR File = sshbuf-misc.c, Line = 225
>   A value of type "int" cannot be assigned to an entity of type
> "void *".
> 
>         if ((p = memmem(sshbuf_ptr(b) + start_offset,
> 
> This can be easily fixed by changing line 215 from void *p to 
> to size_t p

That's not correct, though.  Although it's not standardized, the consensus seems to be memmem returns a void * (http://man7.org/linux/man-pages/man3/memmem.3.html) and that's certainly what OpenSSH expects (https://man.openbsd.org/memmem).

Does IRIX define its own memmem to return an integer type (ie is HAVE_MEMMEM in config.h) or is this a result of a missing prototype?  (It's defined in openbsd-compat.h which is pulled in via includes.h, but it's possible there might be some reason it doesn't work).
Comment 2 Ole Weidner 2019-12-07 05:39:21 AEDT
HAVE_MEMMEM is not defined in config.h and I couldn't find any traces of it in the IRIX system includes.
Comment 3 Darren Tucker 2019-12-09 12:55:14 AEDT
Created attachment 3342 [details]
check if memmem is declared and use for compat prototype

(In reply to Ole Weidner from comment #2)
> HAVE_MEMMEM is not defined in config.h and I couldn't find any
> traces of it in the IRIX system includes.

If you don't have HAVE_MEMMEM in config.h then I'm not sure what's going on.  You could check config.log and look for the memmem test output.

I did find one way to reproduce a similar error: where configure is picking up a memmem from somewhere (maybe libc, or maybe one of the other dependencies, I reproduced with gcc and a -lmemmem in LIBS) but that will result in HAVE_MEMMEM in config.h.

The compat code only defines the prototype #ifndef HAVE_MEMMEM, thus in this case nothing defines it so it defaults to int and you get the mismatch.

The attached patch fixes what I found  (note that you will need to run autoreconfig from autoconf 2.69 to rebuild configure before running it).  It's worth trying for your case too.

The other potential gotcha: if you have a different config.h elsewhere in your search path you might not be using the one you think you are.
Comment 4 Darren Tucker 2019-12-16 14:26:33 AEDT
I've committed that diff, I would be interested to know whether or not it makes a difference in this case.  You can try as snapshot (https://www.mindrot.org/openssh_snap/) or current git tree.
Comment 5 Ole Weidner 2019-12-18 08:10:14 AEDT
The diff indeed makes a difference and openssh compiles without any issue now The following warning pops up during linkage:

ld32: WARNING 84 : openbsd-compat/libopenbsd-compat.a is not used for resolving any symbol.

The executable works fine.
Comment 6 Damien Miller 2021-04-23 14:59:57 AEST
closing resolved bugs as of 8.6p1 release