Changeset 481 for trunk/src/sh_tools.c


Ignore:
Timestamp:
Jul 18, 2015, 5:06:52 PM (9 years ago)
Author:
katerina
Message:

Enhancements and fixes for tickets #374, #375, #376, #377, #378, and #379.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_tools.c

    r472 r481  
    109109    p = (_("Key passed is not valid"));
    110110  else if (err_num == BAD_CIPHER_MODE)
    111     p = (_("Params struct passed to cipherInit invalid"));
     111    p = (_("Params struct passed to rijndael_cipherInit invalid"));
    112112  else if (err_num == BAD_CIPHER_STATE)
    113113    p = (_("Cipher in wrong state"));
     
    13711371#if defined (SH_WITH_CLIENT) || defined (SH_WITH_SERVER)
    13721372
     1373#if defined (SH_WITH_CLIENT)
     1374
     1375static int           probe_done = S_FALSE;
     1376static unsigned char probe_flag = '\0';
     1377
     1378void sh_tools_probe_reset()
     1379{
     1380  probe_done = S_FALSE;
     1381  probe_flag = '\0';
     1382  return;
     1383}
     1384
     1385static int probe_ok(int flag)
     1386{
     1387  (void) flag;
     1388  if ((probe_flag & SH_PROTO_IVA) != 0)
     1389    return S_TRUE;
     1390  return S_FALSE;
     1391}
     1392
     1393static unsigned char probe_header_set(unsigned char protocol)
     1394{
     1395  if (probe_done || (protocol & SH_PROTO_SRP) == 0)
     1396    return 0;
     1397
     1398  return (char) SH_PROTO_IVA;
     1399}
     1400
     1401static void probe_header_get(unsigned char protocol)
     1402{
     1403  if (probe_done || (protocol & SH_PROTO_SRP) == 0)
     1404    return;
     1405
     1406  /* If the server doesn't know about it,
     1407   * it will simply mirror it back. */
     1408 
     1409  if ((protocol & SH_PROTO_IVA) != 0)
     1410    {
     1411      /* probe was mirrored */;
     1412    }
     1413  else
     1414    {
     1415      /* probe was UNset */
     1416      probe_flag |= SH_PROTO_IVA;
     1417    }
     1418  probe_done = S_TRUE;
     1419  return;
     1420}
     1421
     1422#else
     1423static unsigned char probe_header_set(unsigned char protocol) {
     1424  (void) protocol; return 0; }
     1425static void probe_header_get(unsigned char protocol) {
     1426  (void) protocol; return; }
     1427void sh_tools_probe_reset() { return; }
     1428
     1429unsigned char sh_tools_probe_store(unsigned char protocol, int * probe_flag)
     1430{
     1431  if ((protocol & SH_PROTO_SRP) == 0)
     1432    return protocol;
     1433
     1434  if ((protocol & SH_PROTO_IVA) != 0)
     1435    {
     1436      /* probe received */
     1437      *probe_flag |=  SH_PROTO_IVA;
     1438      protocol    &= ~SH_PROTO_IVA;
     1439    }
     1440  return protocol;
     1441}
     1442
     1443static int probe_ok(int flag)
     1444{
     1445  if ((flag & SH_PROTO_IVA) != 0)
     1446    return S_TRUE;
     1447  return S_FALSE;
     1448}
     1449#endif
     1450
     1451
    13731452void get_header (unsigned char * head, unsigned long * bytes, char * u)
    13741453{
    13751454  SL_ENTER(_("get_header"));
     1455
     1456  probe_header_get(head[0]);
    13761457
    13771458  *bytes =
     
    13931474#if defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER)
    13941475
    1395 #ifdef  SH_ENCRYPT_2
     1476#ifdef  SH_ENCRYPT
    13961477#define TRANS_BYTES 65120
    13971478#else
     
    13991480#endif
    14001481
    1401 void put_header (unsigned char * head, int protocol,
     1482void put_header (unsigned char * head, const int protocol,
    14021483                 unsigned long * length, char * u)
    14031484{
     1485  unsigned char probe = probe_header_set(protocol);
    14041486
    14051487  /* static long transfer_limit = (8 * SH_BUFSIZE); V0.8 */
     
    14081490  SL_ENTER(_("put_header"));
    14091491
    1410   head[0]   = protocol;
     1492  head[0]   = protocol|probe;
    14111493
    14121494  ASSERT((*length < transfer_limit), _("*length < transfer_limit"))
     
    14341516  SL_RET0(_("put_header"));
    14351517}
    1436 #endif
    14371518
    14381519/* ------------------------------------------
     
    14531534 * only SH_V2_FULLSIZE is used, and only once
    14541535 */
    1455 #if 0
    1456 #ifdef SH_WITH_SERVER
    1457 #define SH_V2_FULLSIZE  240
    1458 #define SH_V2_PAYLOAD   224
    1459 #define SH_V2_MESSAGE   176
    1460 #else
    1461 #define SH_V2_FULLSIZE 1024
    1462 #define SH_V2_PAYLOAD  1008
    1463 #define SH_V2_MESSAGE   960
    1464 #endif
    1465 #endif
     1536
    14661537#define SH_V2_FULLSIZE 1024
    14671538
     
    15081579
    15091580#ifdef SH_ENCRYPT
     1581
    15101582/*
    15111583 * #define DEBUG_EN2
     
    15141586 * last 4 bytes of outgoing header are set to dummy value
    15151587 */
    1516 char * sh_tools_makePack (unsigned char * header,
     1588char * sh_tools_makePack (unsigned char * header, int flag,
    15171589                          char * payload, unsigned long payload_size,
    15181590                          keyInstance * keyInstE)
    15191591{
    1520   UINT32 rpad[3];
     1592  BYTE            inBlock[B_SIZ];
     1593  BYTE            outBlock[B_SIZ];
     1594  char            ivBlock[B_SIZ];
     1595
     1596  UINT32          rpad[3];
    15211597  unsigned char   head[16];
    1522   double epad;
    1523   unsigned long    i_epad = 0;
    1524   unsigned long    i_blk = payload_size / 16;
    1525   unsigned long    i_blkmax = SH_V2_FULLSIZE / 16;
    1526   unsigned long    pads = 0;
    1527   size_t full_size;
    1528   char * full_ret;
    1529 
    1530   char                  * p;
    1531   RIJ_BYTE                    inBlock[B_SIZ];
    1532   RIJ_BYTE                    outBlock[B_SIZ];
    1533   int                     j;
    1534   cipherInstance          cipherInst;
    1535   int                     err_num;
    1536   int                     blkfac;
    1537   int                     oflow = 0;
     1598  double          epad;
     1599  unsigned long   i_epad = 0;
     1600  unsigned long   i_blk = payload_size / 16;
     1601  unsigned long   i_blkmax = SH_V2_FULLSIZE / 16;
     1602  unsigned long   pads = 0;
     1603  size_t          full_size;
     1604  char          * full_ret;
     1605
     1606  unsigned char * p;
     1607  int             j;
     1608  cipherInstance  cipherInst;
     1609  int             err_num;
     1610  int             blkfac;
     1611  int             oflow = 0;
     1612  char expbuf[SH_ERRBUF_SIZE];
    15381613
    15391614  /*
     
    15411616  */
    15421617  if ((i_blk * 16) != payload_size) ++i_blk;
    1543 #ifdef DEBUG_EN2
    1544   fprintf(stderr, "SEND <%d> blocks <%d>\n", payload_size, i_blk);
    1545 #endif
     1618
    15461619  /* random_pad
    15471620   */
     
    15531626  memcpy (&head[8],  &rpad[2],    4);
    15541627
    1555   /* protocol
    1556    */
    1557   /* memcpy (&head[8],  &header[3], 4); */
    1558 
    15591628  /* size (payload)
    15601629   */
     
    15661635  if (i_blk < i_blkmax)
    15671636  {
    1568     pads = i_blkmax - i_blk;
    1569     /* memcpy((char *) &rpad[2], &head[12], 4); */
    1570     epad = taus_get_double (&rpad);
    1571 #ifdef DEBUG_EN2
    1572     fprintf(stderr, "PAD1 <%d> <%f>\n", pads, epad);
    1573 #endif
     1637    pads   = i_blkmax - i_blk;
     1638    epad   = taus_get_double (&rpad);
    15741639    i_epad = (unsigned long) (pads * epad);
    1575 #ifdef DEBUG_EN2
    1576     fprintf(stderr, "PAD2 <%d> <%d>\n", i_epad, (i_epad*16));
    1577 #endif
    15781640  }
    15791641
     
    15961658
    15971659  full_ret = SH_ALLOC(full_size);
     1660
    15981661  memcpy(full_ret,                   head,    16);
    15991662  if (payload != NULL && !oflow)
    1600     {
    1601       memcpy(&full_ret[16],              payload, payload_size);
    1602     }
     1663    memcpy(&full_ret[16],              payload, payload_size);
     1664
    16031665  if ((i_blk*16) > payload_size && !oflow)
    16041666    {
    1605 #ifdef DEBUG_EN2
    1606       fprintf(stderr, "SEN2 <%d>\n", (i_blk*16) - payload_size);
    1607 #endif
    16081667      memset(&full_ret[16+payload_size], '\0', (i_blk*16) - payload_size);
    16091668      payload_size = i_blk * 16;
    16101669    }
    16111670  memset(&full_ret[16+payload_size], '\0', i_epad*16);
    1612 #ifdef DEBUG_EN2
    1613   fprintf(stderr, "SEN3 <%d> <%d>\n", full_size, i_epad*16);
    1614 #endif
    16151671
    16161672  /* rewrite header
     
    16181674  header[1]   = (unsigned int)(full_size/256);
    16191675  header[2]   = (unsigned int)(full_size - (256 * header[1]));
    1620   /* don't erase protocol from header
    1621      memset(&header[3], '\0', 4);
    1622   */
    1623   p = full_ret; blkfac = full_size / 16;
    1624 
    1625   err_num = cipherInit (&cipherInst, MODE_CBC, NULL);
     1676
     1677  p      = (unsigned char *) full_ret;
     1678  blkfac = full_size / B_SIZ;
     1679
     1680  err_num = rijndael_cipherInit (&cipherInst, MODE_CBC, NULL);
    16261681 
    1627   if (err_num < 0)
    1628     {
    1629       char expbuf[SH_ERRBUF_SIZE];
    1630       sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
    1631                       errorExplain(err_num, expbuf, sizeof(expbuf)),
    1632                       _("sh_tools_makePack: cipherInit"));
    1633     }
    1634   for (j = 0; j < blkfac; ++j)
    1635     {
     1682  if (err_num < 0) {
     1683    sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     1684                    errorExplain(err_num, expbuf, sizeof(expbuf)),
     1685                    _("sh_tools_makePack: rijndael_cipherInit")); }
     1686
     1687  if (probe_ok(flag)) {
     1688    memcpy(inBlock, p, B_SIZ);
     1689    err_num = rijndael_blockEncrypt(&cipherInst, keyInstE,
     1690                                    inBlock, 128, outBlock);
     1691    if (err_num >= 0) {
     1692      memcpy(p, outBlock, B_SIZ); p += B_SIZ;
     1693      memcpy(ivBlock, outBlock, sizeof(ivBlock));
     1694      err_num = rijndael_cipherInit (&cipherInst, MODE_CBC, ivBlock);
     1695      if (err_num >= 0) {
     1696        err_num = rijndael_blockEncrypt(&cipherInst, keyInstE,
     1697                                        p, 128*(blkfac-1), p);
     1698      }
     1699    }
     1700  }
     1701
     1702  else {
     1703    for (j = 0; j < blkfac; ++j) {
    16361704      memcpy(inBlock, p, B_SIZ);
    1637       err_num = blockEncrypt(&cipherInst, keyInstE,
    1638                              inBlock, 128 * BNUM, outBlock);
    1639       if (err_num < 0)
    1640         {
    1641           char expbuf[SH_ERRBUF_SIZE];
    1642           sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
    1643                           errorExplain(err_num, expbuf, sizeof(expbuf)),
    1644                           _("sh_tools_makePack: blockEncrypt"));
    1645         }
     1705      err_num = rijndael_blockEncrypt(&cipherInst, keyInstE,
     1706                                      inBlock, 128, outBlock);
     1707     
     1708      if (err_num < 0) {
     1709        sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     1710                        errorExplain(err_num, expbuf, sizeof(expbuf)),
     1711                        _("sh_tools_makePack: rijndael_blockEncrypt"));
     1712        break; }
     1713     
    16461714      memcpy(p, outBlock, B_SIZ);
    16471715      p += B_SIZ;
    16481716    }
     1717  }
    16491718
    16501719  return full_ret;
     
    16541723 * last 4 bytes of incoming header are dummy
    16551724 */
    1656 char * sh_tools_revertPack (unsigned char * header, char * message,
     1725char * sh_tools_revertPack (unsigned char * header, int flag, char * message,
    16571726                            keyInstance * keyInstD,
    16581727                            unsigned long message_size)
    16591728{
     1729  BYTE                    inBlock[B_SIZ];
     1730  BYTE                    outBlock[B_SIZ];
     1731  char                    ivBlock[B_SIZ];
    16601732  unsigned long   msg_size;
    16611733  char          * msg_ret;
    16621734
    1663   char                  * p;
    1664   RIJ_BYTE                    inBlock[B_SIZ];
    1665   RIJ_BYTE                    outBlock[B_SIZ];
     1735  unsigned char         * p;
    16661736  int                     j;
    16671737  cipherInstance          cipherInst;
     
    16711741
    16721742  msg_size = (256 * (unsigned int)header[1] + (unsigned int)header[2]);
    1673 #ifdef DEBUG_EN2
    1674   fprintf(stderr, "RECV <%lu>\n", msg_size);
    1675 #endif
    1676   if (msg_size > message_size) {
     1743  if (msg_size > message_size)
    16771744    msg_size = message_size;
    1678 #ifdef DEBUG_EN2
    1679     fprintf(stderr, "RECV TRUNC1 <%lu>\n", msg_size);
    1680 #endif
    1681   }
    1682 
    1683   p = message; blkfac = msg_size / 16;
    1684 
    1685   err_num = cipherInit (&cipherInst, MODE_CBC, NULL);
     1745
     1746  p = (unsigned char *) message; blkfac = msg_size / 16;
     1747
     1748  err_num = rijndael_cipherInit (&cipherInst, MODE_CBC, NULL);
    16861749 
    16871750  if (err_num < 0)
     
    16891752      sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
    16901753                      errorExplain(err_num, expbuf, sizeof(expbuf)),
    1691                       _("sh_tools_revertPack: cipherInit"));
    1692     }
    1693   for (j = 0; j < blkfac; ++j)
    1694     {
     1754                      _("sh_tools_revertPack: rijndael_cipherInit"));
     1755    }
     1756
     1757  if (probe_ok(flag)) {
     1758    memcpy(inBlock, p, B_SIZ);
     1759    err_num = rijndael_blockDecrypt(&cipherInst, keyInstD,
     1760                                    inBlock, 128, outBlock);
     1761    if (err_num >= 0) {
     1762      memcpy(p, outBlock, B_SIZ); p += B_SIZ;
     1763      memcpy(ivBlock, inBlock, sizeof(ivBlock));
     1764      err_num = rijndael_cipherInit (&cipherInst, MODE_CBC, ivBlock);
     1765      if (err_num >= 0) {
     1766        err_num = rijndael_blockDecrypt(&cipherInst, keyInstD,
     1767                                        p, 128*(blkfac-1), p);
     1768      }
     1769    }
     1770  }
     1771
     1772  else {
     1773    for (j = 0; j < blkfac; ++j) {
    16951774      memcpy(inBlock, p, B_SIZ);
    1696       err_num = blockDecrypt(&cipherInst, keyInstD,
    1697                              inBlock, 128 * BNUM, outBlock);
    1698       if (err_num < 0)
    1699         {
    1700           sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
    1701                           errorExplain(err_num, expbuf, sizeof(expbuf)),
    1702                           _("sh_tools_revertPack: blockDecrypt"));
    1703         }
     1775      err_num = rijndael_blockDecrypt(&cipherInst, keyInstD,
     1776                                      inBlock, 128, outBlock);
     1777 
     1778      if (err_num < 0) {
     1779        sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN,
     1780                        errorExplain(err_num, expbuf, sizeof(expbuf)),
     1781                        _("sh_tools_revertPack: rijndael_blockDecrypt"));
     1782        break; }
     1783     
    17041784      memcpy(p, outBlock, B_SIZ);
    17051785      p += B_SIZ;
    17061786    }
    1707  
     1787  }
     1788
    17081789  /* rewrite size in header
    17091790   */
     
    17171798      header[1]   = (unsigned int)(msg_size/256);
    17181799      header[2]   = (unsigned int)(msg_size - (256 * header[1]));
    1719 #ifdef DEBUG_EN2
    1720       fprintf(stderr, "RECV TRUNC2 <%lu>\n", msg_size);
    1721 #endif
    1722     }
    1723 #ifdef DEBUG_EN2
    1724   fprintf(stderr, "REC2 <%lu>\n", msg_size);
    1725 #endif
    1726   /* protocol
    1727    */
    1728   /* memcpy(&header[3], &message[8], 4); */
     1800    }
    17291801
    17301802  /* payload
     
    17321804  msg_ret = SH_ALLOC(msg_size+1);
    17331805  if (msg_size > 0)
    1734     {
    1735       memcpy(msg_ret, &message[16], msg_size);
    1736     }
     1806    memcpy(msg_ret, &message[16], msg_size);
    17371807  msg_ret[msg_size] = '\0';
    1738 #ifdef DEBUG_EN2
    1739   fprintf(stderr, "REC3 <%lu>\n", msg_size);
    1740 #endif
     1808
    17411809  SH_FREE(message);
    1742 
    17431810  return msg_ret;
    17441811}
    1745 #endif
     1812#endif /* #ifdef SH_ENCRYPT */
    17461813
    17471814int sh_tools_hash_add(char * key, char * buf, int buflen)
     
    17811848  SL_RETURN((1), _("sh_tools_hash_vfy"));
    17821849}
     1850
     1851#endif /* defined(SH_WITH_CLIENT) || defined(SH_WITH_SERVER) */
     1852
    17831853
    17841854/* ------------------------------------------ */
     
    18681938#if defined (SH_WITH_SERVER)
    18691939
    1870 char * get_client_conf_file (char * peer, unsigned long * length)
     1940char * get_client_conf_file (const char * peer, unsigned long * length)
    18711941{
    18721942  char * ret;
     
    18741944  struct stat buf;
    18751945  char * base;
    1876   size_t size;
    18771946
    18781947  SL_ENTER(_("get_client_conf_file"));
    18791948
    18801949  base = sh_util_strdup(DEFAULT_DATAROOT);
    1881 
    1882   size = sl_strlen(base);
    1883   if (sl_ok_adds(size, sl_strlen(peer)))
    1884       size += sl_strlen(peer);
    1885   if (sl_ok_adds(size, 6))
    1886     size += 6;
    1887 
    1888   ret = SH_ALLOC(size);
    1889   sl_strlcpy(ret, base, size);
    1890   sl_strlcat(ret, _("/rc."), size);
    1891   sl_strlcat(ret, peer, size);
    1892  
     1950  ret = sh_util_strconcat(base, _("/rc."), peer, NULL);
     1951  if (!ret)
     1952    { SH_FREE(base); *length = 0; SL_RETURN(NULL, _("get_client_conf_file")); }
     1953
    18931954  status = retry_stat (FIL__, __LINE__, ret, &buf);
    1894 
    18951955  if (status == 0)
    18961956    goto lab_end;
     
    18991959                    (long) sh.effective.uid, ret);
    19001960
    1901   sl_strlcpy(ret, base, size);
    1902   sl_strlcat(ret, "/rc", size);
     1961  SH_FREE(ret); ret = sh_util_strconcat(base, _("/rc"), NULL);
     1962  if (!ret)
     1963    { SH_FREE(base); *length = 0; SL_RETURN(NULL, _("get_client_conf_file")); }
    19031964 
    19041965  status = retry_stat (FIL__, __LINE__, ret, &buf);
    1905 
    19061966  if (status == 0)
    19071967    goto lab_end;
     
    19101970                    (long) sh.effective.uid, ret);
    19111971
    1912   SH_FREE(base);
    1913   SH_FREE(ret);
    1914   *length=0;
     1972  SH_FREE(base); SH_FREE(ret); *length=0;
    19151973  SL_RETURN(NULL, _("get_client_conf_file"));
    19161974
     
    19201978      sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, status, MSG_E_SUBGEN,
    19211979                    _("File too large"), _("get_client_conf_file"));
    1922       SH_FREE(base);
     1980      SH_FREE(base); SH_FREE(ret); *length = 0;
    19231981      SL_RETURN(NULL, _("get_client_conf_file"));
    19241982    }
    1925   *length = (unsigned long) buf.st_size;
    1926   SH_FREE(base);
     1983
     1984  SH_FREE(base); *length = (unsigned long) buf.st_size;
    19271985  SL_RETURN(ret, _("get_client_conf_file"));
    19281986}
    19291987
    1930 char * get_client_data_file (char * peer, unsigned long * length)
     1988char * get_client_data_file (const char * peer, unsigned long * length)
    19311989{
    19321990  char * ret;
    19331991  int    status;
    19341992  struct stat buf;
    1935 
    19361993  char * base;
    1937   size_t size;
    19381994
    19391995  SL_ENTER(_("get_client_data_file"));
    19401996
    19411997  base = sh_util_strdup(DEFAULT_DATAROOT);
    1942 
    1943   size = sl_strlen(base);
    1944   if (sl_ok_adds(size, sl_strlen(peer)))
    1945       size += sl_strlen(peer);
    1946   if (sl_ok_adds(size, 8))
    1947     size += 8;
    1948 
    1949   ret = SH_ALLOC(size);
    1950   sl_strlcpy(ret, base, size);
    1951   sl_strlcat(ret, _("/file."), size);
    1952   sl_strlcat(ret, peer, size);
    1953  
     1998  ret = sh_util_strconcat(base, _("/file."), peer, NULL);
     1999  if (!ret)
     2000    { SH_FREE(base); *length = 0; SL_RETURN(NULL, _("get_client_data_file")); }
     2001
    19542002  status = retry_stat (FIL__, __LINE__, ret, &buf);
    1955 
    19562003  if (status == 0)
    19572004    goto lab1_end;
     
    19602007                    (long) sh.effective.uid, ret);
    19612008
    1962 
    1963   sl_strlcpy(ret, base, size);
    1964   sl_strlcat(ret, _("/file"), size);
    1965  
     2009  SH_FREE(ret);
     2010  ret = sh_util_strconcat(base, _("/file"), NULL);
     2011  if (!ret)
     2012    { SH_FREE(base); *length = 0; SL_RETURN(NULL, _("get_client_data_file")); }
     2013
    19662014  status = retry_stat (FIL__, __LINE__, ret, &buf);
    1967 
    19682015  if (status == 0)
    19692016    goto lab1_end;
     
    19722019                    (long) sh.effective.uid, ret);
    19732020
    1974 
    1975   *length = 0;
    1976   SH_FREE(base);
    1977   SH_FREE(ret);
     2021  *length = 0; SH_FREE(base); SH_FREE(ret);
    19782022  SL_RETURN(NULL, _("get_client_data_file"));
    19792023
     
    19832027      sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, status, MSG_E_SUBGEN,
    19842028                    _("File too large"), _("get_client_data_file"));
    1985       SH_FREE(base);
     2029      SH_FREE(base); SH_FREE(ret); *length = 0;
    19862030      SL_RETURN(NULL, _("get_client_data_file"));
    19872031    }
     2032
     2033  *length = (unsigned long) buf.st_size; SH_FREE(base);
     2034  SL_RETURN(ret, _("get_client_data_file"));
     2035}
     2036
     2037char * get_client_uuid_file (const char * peer, unsigned long * length, const char * uuid)
     2038{
     2039  char * ret;
     2040  int    status;
     2041  struct stat buf;
     2042  char * base;
     2043
     2044  SL_ENTER(_("get_client_uuid_file"));
     2045
     2046  base = sh_util_strdup(DEFAULT_DATAROOT);
     2047  ret = sh_util_strconcat(base, _("/file."), peer, ".", uuid, NULL);
     2048  SH_FREE(base);
     2049  if (!ret)
     2050    { *length = 0; SL_RETURN(NULL, _("get_client_uuid_file")); }
     2051
     2052  status = retry_stat (FIL__, __LINE__, ret, &buf);
     2053  if (status != 0)
     2054    {
     2055      sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, status, MSG_E_ACCESS,
     2056                      (long) sh.effective.uid, ret);
     2057      SH_FREE(ret); *length = 0;
     2058      SL_RETURN(NULL, _("get_client_uuid_file"));
     2059    }
     2060  else if (buf.st_size > 0x7fffffff)
     2061    {
     2062      sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, status, MSG_E_SUBGEN,
     2063                    _("File too large"), _("get_client_uuid_file"));
     2064      SH_FREE(ret); *length = 0;
     2065      SL_RETURN(NULL, _("get_client_data_file"));
     2066    }
     2067
    19882068  *length = (unsigned long) buf.st_size;
    1989   SH_FREE(base);
    1990   SL_RETURN(ret, _("get_client_data_file"));
    1991  
    1992 }
     2069  SL_RETURN(ret, _("get_client_uuid_file"));
     2070}
     2071
    19932072#endif
    19942073
     
    20912170  if (SL_ISERROR(fd))
    20922171    {
    2093       sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, fd, MSG_E_SUBGEN,
     2172      sh_error_handle((-1), FIL__, __LINE__, fd, MSG_E_SUBGEN,
    20942173                      _("Error opening temporary file"), _("open_tmp"));
    20952174      TPT(( 0, FIL__, __LINE__, _("msg=<Error %d temporary file %s>\n"),
    20962175            fd, file));
    20972176    }
    2098  
    20992177
    21002178  SH_FREE (file);
Note: See TracChangeset for help on using the changeset viewer.