尽量用strncpy

    技术2022-05-20  54

    在做字符串拷贝的时候,尤其在不明确源字符串长度的情况,最好使用strncpy来做,以确保不溢出。

    如遇到的例子: 

      uint8_t *strPlace = buf + sizeof(mysql_hdr) + 9 + 23;

    //strcpy(mssql->loginInfo.UserName, strPlace);  strncpy(mssql->loginInfo.UserName, strPlace,255);


    最新回复(0)