~ubuntu-branches/ubuntu/gutsy/samba/gutsy-updates

« back to all changes in this revision

Viewing changes to source/libsmb/asn1.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2006-11-28 20:14:37 UTC
  • mfrom: (0.10.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061128201437-a6x4lzlhempazocp
Tags: 3.0.23d-1ubuntu1
* Merge from debian unstable.
* Drop python2.4-samba, replace with python-samba. Added Conflicts/Replaces
  on python2.4-samba
* Drop track-connection-dos.patch, ubuntu-winbind-panic.patch, 
  ubuntu-fix-ldap.patch, ubuntu-setlocale.patch, ubuntu-setlocale-fixes.patch
* Remaining Ubuntu changes:
  - Revert Debian's installation of mount.cifs and umount.cifs as suid
  - Comment out the default [homes] shares and add more verbose comments to
    explain what they do and how they work (closes: launchpad.net/27608)
  - Add a "valid users = %S" stanza to the commented-out [homes] section, to
    show users how to restrict access to \\server\username to only username.
  - Change the (commented-out) "printer admin" example to use "@lpadmin"
    instead of "@ntadmin", since the lpadmin group is used for spool admin.
  - Alter the panic-action script to encourage users to report their
    bugs in Ubuntu packages to Ubuntu, rather than reporting to Debian.
    Modify text to more closely match the Debian script
  - Munge our init script to deal with the fact that our implementation
    (or lack thereof) of log_daemon_msg and log_progress_msg differs
    from Debian's implementation of the same (Ubuntu #19691)
  - Kept ubuntu-auxsrc.patch: some auxilliary sources (undocumented in 
    previous changelogs)
  - Set default workgroup to MSHOME

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
{
32
32
        if (data->has_error) return False;
33
33
        if (data->length < data->ofs+len) {
34
 
                uint8 *newp;
35
 
                newp = SMB_REALLOC(data->data, data->ofs+len);
36
 
                if (!newp) {
37
 
                        SAFE_FREE(data->data);
 
34
                data->data = SMB_REALLOC(data->data, data->ofs+len);
 
35
                if (!data->data) {
38
36
                        data->has_error = True;
39
37
                        return False;
40
38
                }
41
 
                data->data = newp;
42
39
                data->length = data->ofs+len;
43
40
        }
44
41
        memcpy(data->data + data->ofs, p, len);
271
268
        }
272
269
 
273
270
        if (!asn1_read_uint8(data, &b)) {
 
271
                SAFE_FREE(nesting);
274
272
                return False;
275
273
        }
276
274
 
277
275
        if (b & 0x80) {
278
276
                int n = b & 0x7f;
279
 
                if (!asn1_read_uint8(data, &b))
 
277
                if (!asn1_read_uint8(data, &b)) {
 
278
                        SAFE_FREE(nesting);
280
279
                        return False;
 
280
                }
281
281
                nesting->taglen = b;
282
282
                while (n > 1) {
283
 
                        if (!asn1_read_uint8(data, &b)) 
 
283
                        if (!asn1_read_uint8(data, &b)) {
 
284
                                SAFE_FREE(nesting);
284
285
                                return False;
 
286
                        }
285
287
                        nesting->taglen = (nesting->taglen << 8) | b;
286
288
                        n--;
287
289
                }
338
340
        pstring oid_str;
339
341
        fstring el;
340
342
 
341
 
        if (!asn1_start_tag(data, ASN1_OID)) return False;
 
343
        *OID = NULL;
 
344
 
 
345
        if (!asn1_start_tag(data, ASN1_OID)) {
 
346
                return False;
 
347
        }
342
348
        asn1_read_uint8(data, &b);
343
349
 
344
350
        oid_str[0] = 0;
359
365
 
360
366
        asn1_end_tag(data);
361
367
 
362
 
        *OID = SMB_STRDUP(oid_str);
 
368
        if (!data->has_error) {
 
369
                *OID = SMB_STRDUP(oid_str);
 
370
        }
363
371
 
364
372
        return !data->has_error;
365
373
}
369
377
{
370
378
        char *id;
371
379
 
372
 
        if (!asn1_read_OID(data, &id)) return False;
 
380
        if (!asn1_read_OID(data, &id)) {
 
381
                return False;
 
382
        }
373
383
 
374
384
        if (strcmp(id, OID) != 0) {
375
385
                data->has_error = True;
383
393
BOOL asn1_read_GeneralString(ASN1_DATA *data, char **s)
384
394
{
385
395
        int len;
386
 
        if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) return False;
 
396
        char *str;
 
397
 
 
398
        *s = NULL;
 
399
 
 
400
        if (!asn1_start_tag(data, ASN1_GENERAL_STRING)) {
 
401
                return False;
 
402
        }
387
403
        len = asn1_tag_remaining(data);
388
404
        if (len < 0) {
389
405
                data->has_error = True;
390
406
                return False;
391
407
        }
392
 
        *s = SMB_MALLOC(len+1);
393
 
        if (! *s) {
 
408
        str = SMB_MALLOC(len+1);
 
409
        if (!str) {
394
410
                data->has_error = True;
395
411
                return False;
396
412
        }
397
 
        asn1_read(data, *s, len);
398
 
        (*s)[len] = 0;
 
413
        asn1_read(data, str, len);
 
414
        str[len] = 0;
399
415
        asn1_end_tag(data);
 
416
 
 
417
        if (!data->has_error) {
 
418
                *s = str;
 
419
        }
400
420
        return !data->has_error;
401
421
}
402
422