diff options
author | Werner Koch <wk@gnupg.org> | 2006-09-14 18:50:33 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2006-09-14 18:50:33 +0200 |
commit | 03d3322e5fb928d48ea4192fd2f2cc851d791421 (patch) | |
tree | 768acc2e54f6e4abcc405e665bf058aa1556d3f5 /scd | |
parent | Various fixes and new features. (diff) | |
download | gnupg2-03d3322e5fb928d48ea4192fd2f2cc851d791421.tar.xz gnupg2-03d3322e5fb928d48ea4192fd2f2cc851d791421.zip |
Take advantage of newer gpg-error features.
Diffstat (limited to 'scd')
-rw-r--r-- | scd/ChangeLog | 8 | ||||
-rw-r--r-- | scd/app-openpgp.c | 20 | ||||
-rw-r--r-- | scd/app-p15.c | 30 | ||||
-rw-r--r-- | scd/app.c | 8 | ||||
-rw-r--r-- | scd/command.c | 4 | ||||
-rw-r--r-- | scd/iso7816.c | 2 |
6 files changed, 40 insertions, 32 deletions
diff --git a/scd/ChangeLog b/scd/ChangeLog index a62b8b06a..4b133c9e8 100644 --- a/scd/ChangeLog +++ b/scd/ChangeLog @@ -1,3 +1,11 @@ +2006-09-14 Werner Koch <wk@g10code.com> + + Replaced all call gpg_error_from_errno(errno) by + gpg_error_from_syserror(). + + * command.c (scd_command_handler): Replaced + init_connected_socket_server by init_socket_server_ext. + 2006-09-07 Werner Koch <wk@g10code.com> * command.c (update_reader_status_file): Execute an event handler diff --git a/scd/app-openpgp.c b/scd/app-openpgp.c index 0e35e097c..0db21781e 100644 --- a/scd/app-openpgp.c +++ b/scd/app-openpgp.c @@ -566,7 +566,7 @@ store_fpr (int slot, int keynumber, u32 timestamp, n = 6 + 2 + mlen + 2 + elen; p = buffer = xtrymalloc (3 + n); if (!buffer) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); *p++ = 0x99; /* ctb */ *p++ = n >> 8; /* 2 byte length header */ @@ -880,7 +880,7 @@ retrieve_key_material (FILE *fp, const char *hexkeyid, break; /* EOF. */ if (i < 0) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; /* Error. */ } if (!max_length) @@ -1036,7 +1036,7 @@ get_public_key (app_t app, int keyno) mbuf = xtrymalloc ( mlen + 1); if (!mbuf) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } *mbuf = 0; @@ -1049,7 +1049,7 @@ get_public_key (app_t app, int keyno) ebuf = xtrymalloc ( elen + 1); if (!ebuf) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } *ebuf = 0; @@ -1091,7 +1091,7 @@ get_public_key (app_t app, int keyno) fpr); if (ret < 0) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } @@ -1099,7 +1099,7 @@ get_public_key (app_t app, int keyno) free (command); if (!fp) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error ("running gpg failed: %s\n", gpg_strerror (err)); goto leave; } @@ -1120,7 +1120,7 @@ get_public_key (app_t app, int keyno) keybuf = xtrymalloc (50 + 2*35 + mlen + elen + 1); if (!keybuf) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } @@ -1260,7 +1260,7 @@ do_readkey (app_t app, const char *keyid, unsigned char **pk, size_t *pklen) *pk = xtrymalloc (*pklen); if (!*pk) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); *pklen = 0; return err; } @@ -1819,7 +1819,7 @@ do_writekey (app_t app, ctrl_t ctrl, template = tp = xtrymalloc_secure (template_len); if (!template) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } *tp++ = 0xC0; @@ -2185,7 +2185,7 @@ do_sign (app_t app, const char *keyidstr, int hashalgo, prompt = malloc (strlen (PROMPTSTRING) + 50); if (!prompt) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); sprintf (prompt, PROMPTSTRING, sigcount); rc = pincb (pincb_arg, prompt, &pinvalue); free (prompt); diff --git a/scd/app-p15.c b/scd/app-p15.c index 8a7732c85..21dbad47a 100644 --- a/scd/app-p15.c +++ b/scd/app-p15.c @@ -520,7 +520,7 @@ parse_certid (app_t app, const char *certid, objidlen /= 2; objid = xtrymalloc (objidlen); if (!objid) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); for (s=certid, i=0; i < objidlen; i++, s+=2) objid[i] = xtoi_2 (s); *r_objid = objid; @@ -1130,14 +1130,14 @@ read_ef_prkdf (app_t app, unsigned short fid, prkdf_object_t *result) + objlen/2 * sizeof(unsigned short))); if (!prkdf) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } prkdf->objidlen = objidlen; prkdf->objid = xtrymalloc (objidlen); if (!prkdf->objid) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (prkdf); goto leave; } @@ -1148,7 +1148,7 @@ read_ef_prkdf (app_t app, unsigned short fid, prkdf_object_t *result) prkdf->authid = xtrymalloc (authidlen); if (!prkdf->authid) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (prkdf->objid); xfree (prkdf); goto leave; @@ -1416,14 +1416,14 @@ read_ef_cdf (app_t app, unsigned short fid, cdf_object_t *result) + objlen/2 * sizeof(unsigned short))); if (!cdf) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } cdf->objidlen = objidlen; cdf->objid = xtrymalloc (objidlen); if (!cdf->objid) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (cdf); goto leave; } @@ -2135,7 +2135,7 @@ read_ef_aodf (app_t app, unsigned short fid, aodf_object_t *result) continue; /* Ready. */ no_core: - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); release_aodf_object (aodf); goto leave; @@ -2272,7 +2272,7 @@ read_ef_tokeninfo (app_t app) app->app_local->serialno = xtrymalloc (objlen); if (!app->app_local->serialno) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); goto leave; } memcpy (app->app_local->serialno, p, objlen); @@ -2368,7 +2368,7 @@ send_certinfo (app_t app, ctrl_t ctrl, const char *certtype, buf = xtrymalloc (9 + certinfo->objidlen*2 + 1); if (!buf) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); p = stpcpy (buf, "P15"); if (app->app_local->home_df) { @@ -2463,7 +2463,7 @@ send_keypairinfo (app_t app, ctrl_t ctrl, prkdf_object_t keyinfo) buf = xtrymalloc (9 + keyinfo->objidlen*2 + 1); if (!buf) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); p = stpcpy (buf, "P15"); if (app->app_local->home_df) { @@ -2544,7 +2544,7 @@ readcert_by_cdf (app_t app, cdf_object_t cdf, { *r_cert = xtrymalloc (cdf->imagelen); if (!*r_cert) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); memcpy (*r_cert, cdf->image, cdf->imagelen); *r_certlen = cdf->imagelen; return 0; @@ -2687,7 +2687,7 @@ do_getattr (app_t app, ctrl_t ctrl, const char *name) { buf = xtrymalloc (9 + prkdf->objidlen*2 + 1); if (!buf) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); p = stpcpy (buf, "P15"); if (app->app_local->home_df) { @@ -3059,7 +3059,7 @@ do_sign (app_t app, const char *keyidstr, int hashalgo, paddedpin = xtrymalloc (aodf->stored_length+1); if (!paddedpin) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (pinvalue); return err; } @@ -3087,7 +3087,7 @@ do_sign (app_t app, const char *keyidstr, int hashalgo, paddedpin = xtrymalloc (aodf->stored_length+1); if (!paddedpin) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); xfree (pinvalue); return err; } @@ -3345,7 +3345,7 @@ app_select_p15 (app_t app) app->app_local = xtrycalloc (1, sizeof *app->app_local); if (!app->app_local) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); goto leave; } @@ -69,7 +69,7 @@ lock_reader (int slot) { if (!pth_mutex_init (&lock_table[slot].lock)) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error ("error initializing mutex: %s\n", strerror (errno)); return err; } @@ -80,7 +80,7 @@ lock_reader (int slot) if (!pth_mutex_acquire (&lock_table[slot].lock, 0, NULL)) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_error ("failed to acquire APP lock for slot %d: %s\n", slot, strerror (errno)); return err; @@ -278,7 +278,7 @@ select_application (ctrl_t ctrl, int slot, const char *name, app_t *r_app) app = xtrycalloc (1, sizeof *app); if (!app) { - err = gpg_error_from_errno (errno); + err = gpg_error_from_syserror (); log_info ("error allocating context: %s\n", gpg_strerror (err)); unlock_reader (slot); return err; @@ -480,7 +480,7 @@ app_get_serial_and_stamp (app_t app, char **serial, time_t *stamp) buf = xtrymalloc (app->serialnolen * 2 + 1); if (!buf) - return gpg_error_from_errno (errno); + return gpg_error_from_syserror (); for (p=buf, i=0; i < app->serialnolen; p +=2, i++) sprintf (p, "%02X", app->serialno[i]); *p = 0; diff --git a/scd/command.c b/scd/command.c index 573a91706..3883bfc5e 100644 --- a/scd/command.c +++ b/scd/command.c @@ -1504,7 +1504,7 @@ cmd_apdu (assuan_context_t ctx, char *line) apdu = hex_to_buffer (line, &apdulen); if (!apdu) { - rc = gpg_error_from_errno (errno); + rc = gpg_error_from_syserror (); goto leave; } if (apdulen) @@ -1603,7 +1603,7 @@ scd_command_handler (int fd) } else { - rc = assuan_init_connected_socket_server (&ctx, fd); + rc = assuan_init_socket_server_ext (&ctx, fd, 2); } if (rc) { diff --git a/scd/iso7816.c b/scd/iso7816.c index 5c62e1371..250ee40d5 100644 --- a/scd/iso7816.c +++ b/scd/iso7816.c @@ -677,7 +677,7 @@ iso7816_read_binary (int slot, size_t offset, size_t nmax, unsigned char *p = xtryrealloc (*result, *resultlen + bufferlen); if (!p) { - gpg_error_t err = gpg_error_from_errno (errno); + gpg_error_t err = gpg_error_from_syserror (); xfree (buffer); xfree (*result); *result = NULL; |