]> git.pld-linux.org Git - packages/gg.git/commitdiff
- encode password
authortiwek <tiwek@pld-linux.org>
Thu, 13 Jun 2002 12:22:00 +0000 (12:22 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    gg-0.2.2.1-base64-password.patch -> 1.1

gg-0.2.2.1-base64-password.patch [new file with mode: 0644]

diff --git a/gg-0.2.2.1-base64-password.patch b/gg-0.2.2.1-base64-password.patch
new file mode 100644 (file)
index 0000000..05f5baf
--- /dev/null
@@ -0,0 +1,161 @@
+diff -ur gg-0.2.2.1.orig/src/main.c gg-0.2.2.1/src/main.c
+--- gg-0.2.2.1.orig/src/main.c Mon Apr 22 11:59:01 2002
++++ gg-0.2.2.1/src/main.c      Thu Jun 13 12:20:39 2002
+@@ -286,7 +286,16 @@
+                       config.uin = atoi(line + 4);
+               }
+               if (g_strncasecmp(line, "password ", 9) == 0) {
++                      char *tmp;
++
+                       config.password = g_strdup(g_strstrip(line + 9));
++
++                      if (*config.password == 1) {
++                              tmp = config.password;
++                              config.password++;
++                              config.password = base64_decode(config.password);
++                              free(tmp);
++                      }
+               }
+               if (g_strncasecmp(line, "email ", 6) == 0) {
+                       config.email = g_strdup(g_strstrip(line + 6));
+@@ -427,6 +436,7 @@
+       FILE *fp;
+       gchar *path;
+       GList *tmp_ignore;
++      gchar *tmp;
+       if (window != NULL) {
+           config.width=window->allocation.width;
+           config.height=window->allocation.height;
+@@ -444,7 +454,13 @@
+       chmod(path, S_IRUSR | S_IWUSR);
+       fprintf(fp, "uin %d\n", config.uin);
+-      fprintf(fp, "password %s\n", config.password);
++
++      if (config.password != NULL) {
++              tmp = base64_encode(config.password);
++              fprintf(fp, "password \1%s\n", tmp);
++              free(tmp);
++      }
++
+       if (config.email != NULL)
+               fprintf(fp, "email %s\n", config.email);
+       fprintf(fp, "auto_away %d\n", config.auto_away);
+diff -ur gg-0.2.2.1.orig/src/support.c gg-0.2.2.1/src/support.c
+--- gg-0.2.2.1.orig/src/support.c      Wed Mar 27 11:35:57 2002
++++ gg-0.2.2.1/src/support.c   Thu Jun 13 12:19:31 2002
+@@ -505,3 +505,105 @@
+       return buf;
+ }
++/*
++ *
++ *    base64_*() - autorstwa brygady RR czyli EKG team'u ;-)
++ *
++ */ 
++
++static char base64_charset[] =
++      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
++
++/*
++ * base64_encode()
++ *
++ * zapisuje ci±g znaków w base64. alokuje pamiêæ. 
++ */
++char *base64_encode(char *buf)
++{
++      char *out, *res;
++      int i = 0, j = 0, k = 0, len = strlen(buf);
++      
++      if (!(res = out = malloc((len / 3 + 1) * 4 + 2))) {
++              g_print("// base64_encode() not enough memory\n");
++              return NULL;
++      }
++      
++      while (j <= len) {
++              switch (i % 4) {
++                      case 0:
++                              k = (buf[j] & 252) >> 2;
++                              break;
++                      case 1:
++                              k = ((buf[j] & 3) << 4) | ((buf[++j] & 240) >> 4);
++                              break;
++                      case 2:
++                              k = ((buf[j] & 15) << 2) | ((buf[++j] & 192) >> 6);
++                              break;
++                      case 3:
++                              k = buf[j++] & 63;
++                              break;
++              }
++              *out++ = base64_charset[k];
++              i++;
++      }
++
++      if (i % 4)
++              for (j = 0; j < 4 - (i % 4); j++, out++)
++                      *out = '=';
++      
++      *out = 0;
++      
++      return res;
++}
++
++/*
++ * base64_decode()
++ *
++ * wczytuje ci±g znaków base64, zwraca zaalokowany buforek.
++ */
++char *base64_decode(char *buf)
++{
++      char *res, *save, *end, *foo, val;
++      int index = 0;
++      
++      if (!(save = res = calloc(1, (strlen(buf) / 4 + 1) * 3 + 2))) {
++              g_print("// base64_decode() not enough memory\n");
++              return NULL;
++      }
++
++      end = buf + strlen(buf);
++
++      while (*buf && buf < end) {
++              if (*buf == '\r' || *buf == '\n') {
++                      buf++;
++                      continue;
++              }
++              if (!(foo = strchr(base64_charset, *buf)))
++                      foo = base64_charset;
++              val = (int)foo - (int)base64_charset;
++              *buf = 0;
++              buf++;
++              switch (index) {
++                      case 0:
++                              *res |= val << 2;
++                              break;
++                      case 1:
++                              *res++ |= val >> 4;
++                              *res |= val << 4;
++                              break;
++                      case 2:
++                              *res++ |= val >> 2;
++                              *res |= val << 6;
++                              break;
++                      case 3:
++                              *res++ |= val;
++                              break;
++              }
++              index++;
++              index %= 4;
++      }
++      *res = 0;
++      
++      return save;
++}
+diff -ur gg-0.2.2.1.orig/src/support.h gg-0.2.2.1/src/support.h
+--- gg-0.2.2.1.orig/src/support.h      Mon Jan 28 15:42:44 2002
++++ gg-0.2.2.1/src/support.h   Thu Jun 13 12:19:15 2002
+@@ -85,3 +85,5 @@
+ gchar *gg_urlencode(gchar * str);
++char *base64_decode(char *);
++char *base64_encode(char *);
This page took 0.082303 seconds and 4 git commands to generate.