[PATCH] Add support for MS Catalog files

Andreas Schneider asn at samba.org
Tue Jul 31 09:55:45 UTC 2018


On Friday, 22 June 2018 20:06:02 CEST Jeremy Allison via samba-technical 
wrote:
> A few more tiny comments inline. Nearly done :-).
> > +	ok = convert_string_talloc(mem_ctx,
> > +				   CH_UTF16LE,
> > +				   CH_UNIX,
> > +				   chksum_ucs2.data,
> > +				   chksum_ucs2.length,
> > +				   (void **)&checksum,
> > +				   &converted_size);
> > +	if (!ok) {
> > +		rc = -1;
> > +		goto done;
> > +	}
> > +
> > +	*pchecksum = talloc_steal(mem_ctx, checksum);
> > +	*pchecksum_size = strlen(checksum + 1);
> 
> Shouldn't the above be:
> 
> 	*pchecksum_size = strlen(checksum) + 1;

And it should be before the talloc_steal() which is not a talloc_move() 
setting checksum to NULL.
 
> > +				goto done;
> > +			}
> > +
> > +			DBG_DEBUG("Parsed NameValue: name=%s, flags=%u, value=%s",
> > +				  name,
> > +				  flags,
> > +				  value);
> > +
> > +			cmp = strcmp(name, "File");
> > +			if (cmp == 0) {
> > +				m->file.name = talloc_steal(m, value);
> > +				m->file.flags = flags;
> > +
> > +				continue;
> > +			}
> > +
> > +			cmp = strcmp(name, "OSAttr");
> > +			if (cmp == 0) {
> > +				m->osattr.value = talloc_steal(m, value);
> > +				m->osattr.flags = flags;
> > +
> > +				continue;
> > +			}
> > +		}
> > +
> > +		ok = mscat_asn1_oid_equal(oid, CAT_MEMBERINFO_OBJID);
> > +		if (ok) {
> > +			char *name;
> 
> Initialize name to NULL please.
> 
> Really nice work Andreas, thanks.
> 
> Just one sylistic comment. Instead of using
> talloc_steal(), can you use talloc_move()
> instead ?
> 
> talloc_move() nulls out the moved pointer,
> making it more likely to crash on erroneous
> reuse rather than corrupt stuff (which is
> preferable IMHO).
> 
> I can't see a place where it matters in this
> code, so feel free to ignore my advice here
> (I won't block the patch if you don't do this :-).

I've also fixed some things with GnuTLS 3.6. We need to allow SHA1 checksums 
:-(


Attached is an updated patchset.


	Andreas

-- 
Andreas Schneider                      asn at samba.org
Samba Team                             www.samba.org
GPG-ID:     8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lib-Add-support-to-parse-MS-Catalog-files.patch
Type: text/x-patch
Size: 46725 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20180731/09b39ba2/0001-lib-Add-support-to-parse-MS-Catalog-files.bin>


More information about the samba-technical mailing list