Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #148679
| From | Lew Pitcher <lew.pitcher@digitalfreehold.ca> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Pointer goes to null |
| Followup-To | comp.lang.c |
| Date | 2020-01-02 08:55 -0500 |
| Organization | The Pitcher Digital Freehold |
| Message-ID | <qukso3$3ql$1@dont-email.me> (permalink) |
| References | <9ba96621-32fb-403e-8241-4a23d84a0167@googlegroups.com> |
Followups directed to: comp.lang.c
m.nasim85@gmail.com wrote:
> hello everybody,
> i have a piece of code that never call or affect pointer 'M', but i
> realize that pointer 'M' change to point to NULL. can someone revise my
> code..
>
> [code]
> void SkeinHash256(u8* M, u64 Ni, u64 No, u8* hash)
> {
> // "SHA3" string + version 0x0001
> u8 cfg[32] = {0x53, 0x48, 0x41, 0x33, 0x01, 0x00, 0x00, 0x00};
> u64* out_size = (u64*) (cfg + 8);
> *out_size = No;
>
> u8 K[32] = {0};
> u64 T[2] = {0};
> u8 G0[32] = {0};
> u8 G1[32] = {0};
>
> u8* type = ((u8*)T) + 15;
>
> u8 zero = 0;
> *type = *type & zero;
> *type = *type | CFG;
> UBI256(K, cfg, T, 256, G0);
>
> *type = *type & zero; // here, 'M' starts pointing to NULL
> [/code]
What Jorgen said.
However, some observations:
1) you use non-standard (and therefore, unknown) types to declare all your
objects. This means that, with the code given, we cannot determine
/anything/ about those objects, including sizeof and format. For all /we/
know, <<u8>> is actually <<long float>>, or even <<struct FILE>>.
2) you set <<out_size>> and <<type>> to point to specific, pre-computed
(magic number) locations in other objects. This is dangerous, especially
as those objects are defined with (to us) indeterminate types. Given
u64 T[2] = {0};
and
u8* type = ((u8*)T) + 15;
does
<<type>> point to a location /within/ T, or /outside/ it?
3) given your demonstrated tendancy to use unknown types and hardcode
displacements within them, are you sure that
UBI256(K, cfg, T, 256, G0);
does not, somehow, walk over the storage set aside for the automatic
variables and parameters of SkeinHash256()? This is where I would look
for answers as to why, after UBI256(), the SkeinHash256() has changed to
NULL.
HTH
--
Lew Pitcher
"In Skills, We Trust"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Pointer goes to null m.nasim85@gmail.com - 2020-01-02 01:34 -0800
Re: Pointer goes to null Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-02 12:47 +0000
Re: Pointer goes to null Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-01-02 08:55 -0500
Re: Pointer goes to null Bart <bc@freeuk.com> - 2020-01-02 18:49 +0000
UB awaits... (Was: Pointer goes to null) gazelle@shell.xmission.com (Kenny McCormack) - 2020-01-02 19:53 +0000
Re: UB awaits... (Was: Pointer goes to null) David Brown <david.brown@hesbynett.no> - 2020-01-02 23:34 +0100
Re: UB awaits... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-03 01:43 +0000
Re: UB awaits... David Brown <david.brown@hesbynett.no> - 2020-01-03 09:50 +0100
Re: UB awaits... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-03 14:30 +0000
Re: UB awaits... David Brown <david.brown@hesbynett.no> - 2020-01-03 17:27 +0100
Re: Pointer goes to null Bart <bc@freeuk.com> - 2020-01-02 14:07 +0000
Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-02 07:29 -0800
Re: Pointer goes to null Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-01-02 10:12 -0800
Re: Pointer goes to null jak <nospam@please.ty> - 2020-01-02 16:46 +0100
Re: Pointer goes to null Barry Schwarz <schwarzb@delq.com> - 2020-01-02 08:50 -0800
Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-03 16:20 -0800
Re: Pointer goes to null Barry Schwarz <schwarzb@delq.com> - 2020-01-03 22:16 -0800
Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-07 03:21 -0800
Re: Pointer goes to null Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-01-07 12:24 -0500
Re: Pointer goes to null Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-01-07 12:38 -0500
Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-15 09:36 -0800
Re: Pointer goes to null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-15 18:36 +0000
Re: Pointer goes to null Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2020-01-15 17:31 -0500
Re: Pointer goes to null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-16 02:20 +0000
Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-17 14:51 -0800
Re: Pointer goes to null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-17 23:32 +0000
Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-17 14:47 -0800
Re: Pointer goes to null Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-17 23:25 +0000
Re: Pointer goes to null James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-15 10:49 -0800
Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-17 14:49 -0800
Re: Pointer goes to null Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-01-07 09:42 -0800
Re: Pointer goes to null m.nasim85@gmail.com - 2020-01-15 09:40 -0800
Re: Pointer goes to null James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-02 22:38 -0500
csiph-web